This topic is locked

How to select certain rows on List page programmatically

1/9/2014 8:28:55 PM
PHPRunner Tips and Tricks
admin

Lets we need to mark some records as selected on initial List page load based on value of one of database fields. Here is the example of automatically selecting records where Horsepower field value is more than 200:

var recsId = pageObj.inlineEdit.getRecsId();

for (i in recsId) {

if (Number($("span[id='edit"+recsId[i]+"_Horsepower']").html())>200)

$("input[name='selection[]'][id='check1_"+recsId[i]+"']").attr('checked','checked');

}
A
Anapolis 3/8/2014



Lets we need to mark some records as selected on initial List page load based on value of one of database fields. Here is the example of automatically selecting records where Horsepower field value is more than 200:

var recsId = pageObj.inlineEdit.getRecsId();

for (i in recsId) {

if (Number($("span[id='edit"+recsId[i]+"_Horsepower']").html())>200)

$("input[name='selection[]'][id='check1_"+recsId[i]+"']").attr('checked','checked');

}



NICE one! Thanks, Sergey! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=74291&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />

W
wedi 7/28/2014

Hallo Sergey.
I found your example for select rows on List page and i have a some problems with it. My target is to select one row on the list page depending on a date field. Inline edit is not allowed.
So i have a list with a field called Meeting_Am and the list is sorted by this field DESC. There are some records in the past and some in the future. When the list page is called the first time i want to select the first record which has a Date in Meeting_Am in the future from now.
Example:
Now is 07/28/2014
:

:

09/09/2014

09/04/2014

08/24/2014

08/03/2014

07/27/2014

07/14/2014

:

:
Depending on now the record with Meeting_Am = 08/03/2014 should be selected when the list page is called the first time
Thanks for your help

wedi

admin 7/28/2014

You can try something like this. Since I cannot test it properly you will have to modify this code a bit.

var today = new Date();

var recsId = pageObj.inlineEdit.getRecsId();

for (i in recsId) {

var d = Date.parse($("span[id='edit"+recsId[i]+"_Meeting_Am']").html());

if (d>=today) {

$("input[name='selection[]'][id='check1_"+recsId[i]+"']").attr('checked','checked');

break;

}

}
W
wedi 7/30/2014

Thanks Sergey, i found what i have todo that your code works for me.
One Question: is it possible to change the backgroundcolor of the row (in my example the row with the Meeting_Am = 08/03/2014) instead?
My mistake was: i mean "select certain rows" is to highlight the row and your code shows, how to set the checkbox of the row(s) for export or print.
Thanks