This topic is locked
[SOLVED]

 Disable inline edit

4/27/2017 1:16:12 PM
ASPRunner.NET General questions
T
Tim author

Hello,
I have a list page with inline editing turned on for 3 fields. I'd like to disable the ability to inline edit one of those fields based on the data in another field in that same record. Anyone know how I would do this?
Thanks,

Tim

Pete K 4/27/2017

Tim, this doesn't directly answer your question but I suspect there's enough info here that you can work it out:
https://xlinesoft.com/asprunnernet/docs/how_to_control_inline_add_edit_functionality_from_script.htm
Hope that helps.

T
Tim author 4/27/2017

Hi Pete,
Thanks for the reply. I had found that page too and suspect that the answer is in there, but I just can't make it out. I'm not seeing something that addresses my need directly, but I could be missing it.
Thanks,

Tim

jadachDevClub member 4/27/2017

Try this. The fields in my scenario are Status and OrderDescription. Obviously you will need to change for your case.
I want to allow users to edit OrderDescription only if the Status is not "3" in inline edit and normal edit.
Edit Page Before Display:

pageObject.setProxyValue("Status", values["Status"]);
Edit Page Javascript Onload:

var ctrlStatus = Runner.getControl(pageid, 'Status');

var ctrlOrderDescription = Runner.getControl(pageid, 'OrderDescription');
if(proxy['Status']==3){

ctrlOrderDescription.setDisabled();

}
ctrlStatus.on('change', function(e){

if (this.getValue() == '3'){

ctrlOrderDescription.setDisabled();

}

else{

ctrlOrderDescription.setEnabled();

}

});
Let me know if that works for you.

T
Tim author 4/28/2017

Thanks so much Jerry! This totally pointed me in right direction. The real trick was using "proxy" to pass variables to JavaScript. That, and remembering that the edit page javascript fires for inline edits as well as the edit page. And my code was even more simple because my "control" field won't be edited on this page, so the last part of your solution (the on change bit) wasn't needed. Here is what I ended up with:
Edit Page: Before display
pageObject.setProxyValue("StaffID", XSession.Session["StaffID"]);

pageObject.setProxyValue("Owner",values["OwnerStaffID"]);
Edit Page: JavaScript OnLoad event
var ctrlAT = Runner.getControl(pageid, 'AssignedTo');
if(proxy['StaffID']!=proxy['Owner']){

ctrlAT.setDisabled();

}
Thanks again for your help.

Tim

jadachDevClub member 4/28/2017

Awesome!! I am happy it helped.