This topic is locked
[SOLVED]

 Make inline Records all editable

1/13/2020 3:06:59 PM
PHPRunner General questions
lefty author

I have the following code on Javascript on load of page. If I just use the one liner pageObj.inlineEdit.editAllRecs(); it works fine. I added code below based on field value , but dose not work either condition. Anything I missed Here?
var ctrlcompleted = Runner.getControl(pageid, 'completed');
if (this.getValue()== 'No') {
pageObj.inlineEdit.editAllRecs();
} else {
};
Also tried this
var ctrlcompleted = Runner.getControl(pageid, 'completed');
if (ctrlcompleted.getValue()=='No') {
pageObj.inlineEdit.editAllRecs();
} else {
};

A
acpan 1/13/2020

Check this tip programatically-open-inline-edit-based-on-other-field-value-in-the-grid and refer to step 4.
It first forms an array of index id that meet the condition in After record processed event,

and passes the array as a javascript proxy variable to Javascript On Load event to be opened using pageObj.inlineEdit.editRecById(recsId[X]) through a loop.
pageObj.inlineEdit.editAllRecs() will open ALL records on the current page, so regardless of conditions, it will open all.
ACP

lefty author 1/13/2020



Check this tip programatically-open-inline-edit-based-on-other-field-value-in-the-grid and refer to step 4.
It first forms an array of index id that meet the condition in After record processed event,

and passes the array as a javascript proxy variable to Javascript On Load event to be opened using pageObj.inlineEdit.editRecById(recsId[X]) through a loop.
pageObj.inlineEdit.editAllRecs() will open ALL records on the current page, so regardless of conditions, it will open all.
ACP


Yes, was looking at that before I posted . I can use either statements above , but not conditionally as in step 4 in your example link. I need to do it conditionally and unfortunately the example does not help me in this case.

Looking at your example I do not see where the conditions are checked? Can you explain further . Are you referring to the proxy array? Note: my records are already in the table as child records. They were inserted automatically from the master table.

A
acpan 1/13/2020

It works, here is the screen cast:

A
acpan 1/13/2020

Checks each row's data in a field called "completed". If data is "No", the Condition is met,

store the record index id in an array and passed to Javascript Onload Event, which will loop through and open the inline edit for the record stored in the array.


Note: This is tested on single table Grid table and not tested on Master-Child Grid table.


Here's the extract from the tip, simplified to your case:
Before Process Event (Initialize variables):



$_SESSION["id_group_index"] = 0;

$_SESSION["id_group_array"] = array();


After Record Process Event (Conditionally form the Array of Record Index ID):



// Start the counter now:

$_SESSION["id_group_index"]++;
if ( $data["completed"] == "No" )

{

array_push($_SESSION["id_group_array"], $_SESSION["id_group_index"]);

}


Before Display Event (Set Proxy Variable to pass to Javascript On Load):



// echo "Before Display:".$_SESSION["id_group_array"];

$pageObject->setProxyValue("id_group_array", $_SESSION["id_group_array"] );


Javascript Onload Event (Process the Conditional Array and Open Inline Edit):


// Get all record IDs using pageObj API on current grid page.

var recsId = pageObj.inlineEdit.getRecsId();
// Get the proxy array now, which contains the index we want inline edit to open.

var id_group_array = proxy['id_group_array'];
// Print Array if needed

// console.log(id_group_array.toString()) ;
// loop through each value in the array and open the inline edit:

// "entry" is the value in the the array.

id_group_array.forEach(function(entry) {

console.log(entry);

pageObj.inlineEdit.editRecById(recsId[entry]);

});
lefty author 1/13/2020



It works, here is the screen cast:



I see . I will have to go over your example and give it a go. Thanks for the reply. Wondering if my event in after table inialized $isRecordEditable with the same code interfering with my conditional statement . But if can't get it to work will try your example.

A
acpan 1/13/2020

This is the Javascript version without using proxy array, but very slow:
Only need this code below in the Javascript Onload Event:


// Get all record IDs using pageObj API on current grid page.

var recsId = pageObj.inlineEdit.getRecsId();
// scan each row and do the condition check and open edit if condition met.

$("tr[id*=gridRow]").each(function() {

var id=$(this).attr('id');

// extract just the number from the id

id = id.substring(7);



// Grid id starts at 4 (by inspecting the source), so -3 to get the first record index

var row_index_id = id-3;



// Replace the fieldname "completed" with your actual fieldname

var completed_status = $("#edit"+id+"_completed").text();



// console.log("id=" + id + " | completed=" + completed_status);



// Open Inline Edit if completed_status == No

if (completed_status == "No")

{

pageObj.inlineEdit.editRecById(recsId[row_index_id]);

}

});


It works but it is very slow as it scans 2 times per record for some reason.

lefty author 1/14/2020



This is the Javascript version without using proxy array, but very slow:
Only need this code below in the Javascript onload Event:


// Get all record IDs using pageObj API on current grid page.

var recsId = pageObj.inlineEdit.getRecsId();
// scan each row and do the condition check and open edit if condition met.

$("tr[id*=gridRow]").each(function() {

var id=$(this).attr('id');

// extract just the number from the id

id = id.substring(7);
// Grid id starts at 4 (by inspecting the source), so -3 to get the first record index

var row_index_id = id-3;
// Replace the fieldname "completed" with your actual fieldname

var completed_status = $("#edit"+id+"_completed").text();
// console.log("id=" + id + " | completed=" + completed_status);
// Open Inline Edit if completed_status == No

if (completed_status == "No")

{

pageObj.inlineEdit.editRecById(recsId[row_index_id]);

}

});


It works but it is very slow as it scans 2 times per record for some reason.


acpan,
Thanks your full code works fine. Great Tip!