cancel
Showing results for 
Search instead for 
Did you mean: 

how to set lead selection row in table control after refresh its data.

Former Member
0 Kudos

as title as said. i refresh table content in term of TimedTrigger control.

questin :

how to set some lead selecton row when i refresh table content

e.g.,i have ten records in my table control.table's page size is five.assume the current lead selection row is sixth recrord when i move to the second page.at this time,someone add a new record into DB then it should be seen in the first row in talbe control.so i refresh the table content ,

<b>1.how to keep the table' lead selection row unchanged,which is to be seen at the seventh record. </b>

<b> 2.how to keep the current page unchanged .of coz which lie on the position of the current lead selection row should to be.</b>

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

If the requirement is to use TimedTrigger, then try this...

<b>1. to keep the table' lead selection row unchanged</b>

In the action you have bound to the TimedTrigger UI element, before reloading the data from DB, you get the reference(say it as 'LSElement') of the element which is lead selected. After reloading operation, you search for the element which equals to 'LSElement', if any one matches, set the lead selection to that element.

<b>2. to keep the current page unchanged</b>

In the same action, after setting the lead selection as said above, use the below said formula to set the FirstVisibleRow property of the table(i.e.)to display the same page where the lead selected element is present.

FirstVisibleRow = (Leadselection / VisibleRowCount) * VisibleRowCount

(i.e) if After all the reload and other operations, if 7th record is lead selected, and Number of rows visible per page is 5,

FirstVisibleRow = (7/5)*5

=1 * 5 =5 => so the second page will be visible now..( 0-4 page1, 5-9 page2,etc.. )

<b>Finally the action for the trigger will look like this,</b>

onActionTrigger()

{

< get the reference of lead selected element>

.

.

< reload operation >

.

.

< search and set the lead selection>

.

.

< calculate and set the first visible row property>

}

I hope this will help you.

Thanks and Regards,

Prabhakar.

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi Wingoal,

Is is working? Otherwise shall we go for someother method?

Reply...

Regards,

Prabhakar.

Former Member
0 Kudos

thanks firstly.

in fact this is a real-time data problem .maybe u oftem met some requirement like this.

u display some data in table control by some order.when someone edit or delete some row record.u must refresh data follow it.so u must find the lead selection row before refresh it and set it.

Former Member
0 Kudos

Hi ,

Instead of timedtrigger control its best to place a "Refresh" button and write an action to it. Lets bring parametermapping into our scenario, In DoModifyView() place the code for parameter mapping, i.e.

if(firstTime)

{

IWDCheckBox chkBox = (IWDCheckBox)view.getElement("CheckBox");

chkBox.mappingOfOnToggle().addSourceMapping("nodeElement","sampleElement");

}

By this parameter mapping, the element You have selected will be called as 'sampleElement' throught the controller.

In my table I have used checkbox for selecting a row, you can use radiobutton also...

In action for refresh button, after reloading the content of the node, check the sampleElement with every element of the updated table, if found, set the leadselection to that element, else the element lead selected, might have been deleted in the DB itself.

This code may help you for this perpose,

wdContext.nodeSample.currentSampleElement.equals(sampleElement);

In this method you can find the element whereever it may be in the table.

Regards,

Prabhakar.

Former Member
0 Kudos

Hi ,

Using a timetrigger to fetch data would be rather confusing for the user. When user is working on some data , it would suddenly change the order. Instead ,a simple refresh button would be more elegant. And the application would also load data only when user needs it , which in my opnion is a better approach.

To set lead selection... wdContext.node<nodename>().setLeadSelection(the index of the element which u want to be lead selected.);

When you clear the node and reload the data again.. if the newly added record is the first record.. then it would automatically be lead selected..

(assumin initializeLeadSelection property of node is set to true.)

Regards

Bharathwaj

Former Member
0 Kudos

Hi,

Displaying the newly added record as the first record in the table depends on how you get the values from the backend.If the newly added record comes first in the result from the backend then it will be shown first in the table.

And if you want to set the leadselection to the first record after refresh, then

wdConext.nodeTable.setLeadSelection(0);

In this case what you can do is after TimedTrigger every time the table is updated,

set the lead selection to first record if it is not done by default.

Former Member
0 Kudos

Hai,

before refresh a table, get the lead selection of the table node, pass it after refresh,

After that simply use wdContext.nodeTable().setLeadSelction(value);

Regards,

Naga