jQWidgets Forums
jQuery UI Widgets › Forums › Grid › allow cells to be editable only under specific conditions
This topic contains 1 reply, has 2 voices, and was last updated by Peter Stoev 11 years ago.
-
Author
-
Hello,
I have been using this framework for a few months now, it is doing what I want it to and it is doing it great.However I am having a really hard time finding appropriate documentation and I always have to take some examples and tweak them in order to achieve what I want to.
So basically I have a grid with a lot of data in it. one of the column is a boolean column represented with checkboxes.
I want only this column to be editable, and ONLY if the value is set to false. (basically we should be able to switch from false to true and then it can not turn back to false)I have done the following:
columns : [ { /* The column with the boolean */ width : '80px', cellClassName: cellClass, editable: editableBool, filtertype: 'bool', text : 'is Ack?', columntype: 'checkbox', datafield : 'ack' }, { /* another column (should not be aditable) */ width : '250px', text : 'MO Addr Name', editable: editableBool, cellClassName: cellClass, datafield : 'moInstance' }, {... lots of other columns I dont want to be editable ...}
I have set “editable:true” within my grid declaration and then I declared a function editableBool similar to cellClass (taken from one of your examples) in order to decide wether or not the column should be editable or not :
/* the function I need */ var editableBool = function (row, dataField, cellText, rowData) { return (rowData['ack']==false && dataField == 'ack'); /*should return true only on 'ack' column where ack==false which is what I need*/ }; /* cellClass function from which I got inspired (this one is working great ;) */ var cellClass = function (row, dataField, cellText, rowData) { /*alarm rows with state=='CLEARED' are in green excepted the 'severity' cell */ if (rowData['state']=='CLEARED' && dataField != 'severity') return 'CLEARED'; var severity = rowData['severity']; return severity; };
So when I put a breakpoint in my editableBool function, it never gets interrogated.. whereas the cellClass function does.
What am I doing wrong?
What would be the most correct way to achieve what I need ? (I know I can always do a dirty workaround with some jq functions afterward but I NEED it to be clean and strong (and reusable))Any help would be greatly appreciated.
Thank you
Hi maz,
editable is a Boolean attribute and can be set to a Boolean value i.e true or false. If you want to disable the editing of specific cell/row, you can use this approach: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/disableeditingofrows.htm?arctic
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.