Change column label on grid (PeopleSoft) - peoplesoft

I'm having problems changing the label of a column on a PeopleSoft grid.
I have this code on the RowInit event of the main record:
Local Grid &Grid;
Local GridColumn &Column;
&Grid = GetGrid(Panel.V91MG_BI_INGMAN, "GRID");
&Column = &Grid.GetColumn("DATO_01");
&Column.Label = "Test";
The grid is composed of a Table record and a Derived/Work record. I need to rename the columns of the Derived record.
This is how the page looks like on designer view:
When I test my page, I receive the following message:
I know the grid is being set correctly, as I can change its label using &Grid.Label = "Hi".
Thanks in advance!

Your peoplecode is correct so far. You should move this code to the page activate event.
Did you set the page field name for this column?

If you want to change label only you can do same without writing code.
Go to page fields properties.
Select tab 'Label'
Select Text Radio and enter column label.

Related

Google Appmaker: Update form based on selected dropdown option

I have an AppMaker app that has a from based off of one address table/datasource. I can get a form with next/prev buttons, but replaced the key field (name) with a dropdown list of all names (a user can start typing names to jump there, with the dropdown showing).
My hope is that when a user selects from the dropdown, the entire form updates and the next/prev buttons work properly as well (there too many records to page thru with next/prev only). I don't have to have next/prev functionality if it complicates things too much.
Currently the dropdown is working, but I cannot get the index for the next/prev buttons set or the rest of the form to reflect the selected dropdown record.
I've tried to set the "onValueEdit" event to something like this...
var selected = widget.value;
var idx = widget.options.indexOf(selected);
console.log("Selected: "+selected+", index = "+idx+"\n");
if(idx < 0) { //...this error is never hit
console.log("Index error - setting to zero!\n");
idx = 0;
}
widget.datasource.loadPage(idx); //...update form?
Two observations via console logging:
The "idx" var is never set to the selected dropdown index reliably, and is
often "0" (tho no error msg ever shows), so the "indexOf()" function
isn't working as expected.
The "selected" var (name) is always correct.
If I call widget.datasource.loadPage(...) with a fixed value (say 5) it has no effect on what is shows in the form either (previous loaded data remains) - obviously not the way to do it :v/
Can you steer a noob in the right direction?
If you are using default App Maker form, then you can see that so-called pager, doesn't actually paginate. It triggers prevItem/nextItem datasource methods, in other words it navigates through datasource items, not pages. Here is a quote from App Maker docs:
nextItem: Selects the next item. For Query Datasources, if the current item is the last item on the page, then this loads the next page and selects the first item on the newly loaded page.
So, if you already have all your items loaded(you set query page size for your datasource to 0), then you need just to change selected item within datasource:
// onValueEdit dropdown event
// assuming, that form and dropdown share same datasource
widget.datasource.selectKey(newValue._key);
If you really have lots of items and it is not feasible to load all of them in one call... then it will be all another story...
UPDATE:
It's important that Options and Value are set as shown in the image below!
However, I had trouble setting them that way (read: wasted hours!) until I wiped them both completely using More options in the binding picklist, and tried again (I had even tried on a brand new app!). I was being forced to choose ..projections.. and then a final field before the OK button would be available.
Not sure if AppMaker is buggy here or there is something simple I'm not understanding!
None of the coding in my original question is required.
Once set this way, binding just works as you would expect it!!
All other fields are set as #datasource.item. and are bound to whatever item is chosen. No Events settings are necessary for the dropdown either, as I thought they might be.
I deleted this page and started again, and replaced the default business name data field with a drop down, I set the dropdown as:
Options: #datasources.Addresses.items
Value: #datasources.Addresses.item
It works fine?! Not sure what happend in my original page!
UPDATE:
So it seems you need to delete both the Value and Options and then re-enter these. The OK will light up when you do.
Also, my original take on App Maker was to build the UI and attach data. That was my first mistake. You build the data then have App Maker build edit/add pages for you.

Drupal select list key in template file

How would I go about getting the key of a select list field in a view template (Row style output)?
The field is added to my view and hidden from display. It contains stuff like:
red|Red
green|Green
blue|Blue
How can I get the selected key (ie. red) for the field in the template?
I was able to print it using:
$view->field['field_color']->view->result[0]->field_field_color[0]['raw']['value']
but I wonder if there is an easier way to get that key.
Thanks in advance.
$row->field_field_color[0]['raw']['value'];

How to access Dynamically Generated Controls not knowing their names

My page generates a list of check boxes at run time. I set the Id of each of these boxes manually by assigning to each the string.Format("checkbox_{0}, n} where n is a running number.
How to I find out the list of checkbox controls from codebehind? I couldn't find them in Page.Form.Controls. Where are they placed?
(I can see the checked checkboxes in Request.Form but that contains client side names of each control.)
Thanks.
-
---More info----
My iterative loop Adds CheckBoxes to a Panel control (created in the mark-up page) as follows:
CheckBox checkbox = new CheckBox();
checkbox.Text = "Add to list";
checkbox.ID = string.Format("checkbox_{0}", n.ToString("0"));
Panel1.Controls.Add(checkbox);
The checkboxes show up nicely on the page. I can tick. When I submit the Http POST stream contains all those ticked ones.
On post back, Panel1.Controls.Count is 0. When the page was first generated, Panel1.Controls.Count was 200, as it contained lots of LieteralControls for layout.
You can use the findcontrol method on page object or parent control object to find that checkbox object. like:
CheckBox chx=(CheckBox)Page.FindControl("Checkbox1");
if(chx!=null)
chx.Checked = false;
you can put this insode the loop also like:
for(int i=0;i<n;i++)
{
CheckBox chx=(CheckBox)Page.FindControl("Checkbox"+n);
if(chx!=null)
chx.Checked = false;
}
On post back, Panel1.Controls.Count is 0. When the page was first generated, Panel1.Controls.Count was 200, as it contained lots of LieteralControls for layout.
If you add controls dynamically in this way, you need to add them again (same ids, same order) on each postback.
Which means you need to persist whatever info you need to add them again. For example, you could store the number of checkboxes in ViewState, then regenerate that number of checkboxes on each post back.

What control to use for display a row from Database

I have something like this
select sum(value) from database.table
And this will display only one number for example : 6546.00
What is the best control that i should use to display the selected data to my .aspx page
I don't want use DatagridView .
I think : label , textbox(onlyRead) , ListVIew or something else ?
If you just want to show the info then just use Label
If you want to Edit and Update the Info then just use Text
box..
If you have more than one info to show then just use Listview..
choice depends on your need..
But for displaying single value on screen then Label is best

Dynamic data population like stackoverflow comments?

I'm trying to create a comment system just like SO has, but first, I'd like to show first 5 comments for a post and show rest if "display all comments" is clicked for the desired reply.
What is the best way of doing this? I really couldn't found a good way for doing what I want. I must be missing something.
For info, comments datasource is a nested repeater in my page. The outer repeater is replies and inner repeater is comments. Currently I'm binding all comments for all results (even if it has 10000 replies.). Also, I don't want to do paging for comments. I just want it to work the same way as SO.
Any ideas?
EDIT: Now I'm thinking of having 2 tables for comments which are:
A table which only has 5 rows of data and will be visible by default. I need filtering to do this. Linq filtering code would be great!
A table which has all the results. No filtering. I have no problems with this one.
So here is what I have for the data:
DataRowView dv = e.Item.DataItem as DataRowView;
if (dv != null)
{
Repeater commentRepeater = e.Item.FindControl("childRepeater") as Repeater;
if (commentRepeater != null)
{
commentRepeater.DataSource = dv.CreateChildView("myrelation");
commentRepeater.DataBind();
}
}
As you can see, I have created a relation between tables in my dataset and I'm binding that datarow to my repeater. I need to do top 5 filtering on the datarow.
Thank you
I suggest to use JSON returned from ASP.NET Web Services with jQuery.
http://www.mikesdotnetting.com/Article/96/Handling-JSON-Arrays-returned-from-ASP.NET-Web-Services-with-jQuery
http://www.electrictoolbox.com/json-data-jquery-php-mysql/
If you want to append the left over items to the current repeater item you could have a button at the end of the coments that is attached to a jquery function that will fetch the rest of the comments for you. Then once the data is recieved your function would just append the comments to the list of other comments mimicing what the repeater was doing and replacing the 'show all' button.
If you don't want to use any ajax to do this then you will probably need to rebind the comments Repeater with a new set of data that is not limited to just the first 5 results.
EDIT: Based on your comment and changes you have editted, I would go with one table with all comments and in the DataBinding of each comment set the row style to visible with a global counter. Once your have more than 5 set the style to a hidden style for each item. When they click the show all button, just switch the style from hidden to visible for the rest comments that are hidden. This will save you duplicating the data for the first 5 items which could turn into a lot of extra rows if there are a lot of answers with comments.

Resources