This topic is locked

Open Inline Edit Based on Field Value

1/14/2020 8:01:01 PM
PHPRunner Tips and Tricks
A
acpan author

Purpose: Open Inline Edit automatically on page load, based on field value.
Note: This is the Javascript version based on the tip Programatically Open Inline Edit based on other field value in the grid
Limitations: This javascript version works for one standalone table, for master-detail table, you still have to use the above URL.
Reference Question in Forum: Make inline Records all editable
Online Manual:Controlling the Inline Add/Edit functionality from script
Result Screencast:


Paste this into Javascript Onload Event and replace the field name "completed" to your actual field name:




// Open Inline Edit when the field "completed" is = "no"
// 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]);

}

});
lefty 1/31/2020

[/quote]
acpan,
Updated:

Just wanted to note on your great tip. I used the code for your full version of this tip ( with Proxy Array ) . When I used just what you supplied above by itself with javascript onload , it did not work as expected although it works with one table. When you need master / details and child records , on same page I would recommend for users to use your full code provided in the links above in your full post ( Proxy Array ) for inline / master / child .
Thanks again for the tip , it's documentation like this that there needs to be more of and you should not have to supply it . Wish we had a separate code repository for just code samples like this. I have some of my own that I am sure users would use.
Great Work.

A
acpan author 1/31/2020

Thanks @John, for your feedback (I have put a limitation to this tip based on your feedback).
Yes, i think a code depository, with supported PHPRunner version number would be really helpful.