jQWidgets Forums
jQuery UI Widgets › Forums › TreeGrid › TreeGrid: Row specific editing
This topic contains 7 replies, has 2 voices, and was last updated by rdolan 11 years ago.
-
Author
-
Hi
I am trying to implment a tree grid where a user will have the ability to edit a column on one row but may not have the ability to enter the same column on the next row. The json data I am returning has a property called IsApprover , which is a boolean. This is used to determine if the user will have the ability to edit the row or not. Previously in the jqxGrid I was able to achieve this using the cellbeginedit function that was defined within the grids column definition, as shown below. It seems the same function using the jqxTreeGrid does not work. Can you tell me how I can achieve this same functionaility using the TreeGrid?
Example using jqxGrid
columns: [
{
text: ‘Total’, datafield: ‘UnitCost’, editable: isEditable, width: 100, cellsalign: ‘right’, cellsformat: ‘d2’,
cellbeginedit: function (row, datafield) {
var rowData = $(“#jqxGrid”).jqxGrid(‘getrowdata’, row);
var isApprover = rowData.IsApprover ;if (isApprover)
return true;
else
return false;}
}
]Regards
Robbie..The method of implementing this for the jqxGrid is in the below link. This cellbeginedit function is exactly what I would like to replicate using the jqxTreeGrid. I cannot seem to find any example of how this can be done in the Tree Grid documenation.
http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/disableeditingofrows.htm?web
Regards
RobbieHi rdolan,
Before using jqxTreeGrid, please look at its Demos and especially the Demos about editing. The TreeGrid is a different widget and has similar but different API. Please, do not take into account that something which is available in jqxGrid is also available in the jqxTreeGrid – these are different widgets with different purpose. The TreeGrid does not have “cellbeginedit” callback function, it has “cellBeginEdit”. Please, look at the columns section in the API Documentation for more information about it. The TreeGrid also have a method called lockRow which disables the editing of a specific row – http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxtreegrid/javascript-tree-grid-lock-row.htm?arctic
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter
Thanks for the quick response. The lock row function does not fit what I am looking for in this case. I want to disable only one column on a row per row level. I have a property in my data that is a boolean that is a hidden column in the grid. I want to check this value on each row to determine if one specific field is editable to the user. All the other columns should still be editable. Basically, if the user is assigned to the row, then the user can edit one specific column on the row. I tried to use the cellBeginEdit function to achieve this. I felt I could return false in this function to prevent editing of the column but it had no effect. Is there any way I could achieve this using the cellBeginEdit
$(“#” + this._ElementID).on(‘cellBeginEdit’, function (event) {
var args = event.args;
// row key
var rowKey = args.key;
// row’s data.
var rowData = args.row;
// column’s data field.
var columnDataField = args.dataField;
// column’s display field.
var columnDisplayField = args.displayField;
// cell’s value.
var value = args.value;var isRowApprover = rowData.IsRowApprover;
if (isRowApprover)
return true;
else {
return false;
}});
Hi rdolan,
If you want to disable the editing of a column, you can simply set its editable property to false.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/,Hi Peter
On one row it will be true , on another it row it will be false. I cannot just set the editable property to false as this would enforce false on each row. I need to evaluate on a row per row basis. I only want to dispable one cell one column in each row, not the entire row. That is why I wanted to use the cellBeginEdit function. You can do this with the jqxGrid but it the same does not apply to the treeGrid. is there any way I can do this in the TreeGrid?
Regards
RobbieHi rdolan,
You’re looking for a feature which is not available in this widget.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/I figured out a way to do this. I was able to use the endUpdate within the cellBeginEdit function.
$(“#treeGrid”).on(‘cellBeginEdit’, function (event) {
var args = event.args;
// row key
var rowKey = args.key;
// row’s data.
var rowData = args.row;
// column’s data field.
var columnDataField = args.dataField;
// column’s display field.
var columnDisplayField = args.displayField;
// cell’s value.
var value = args.value;var isRowApprover = rowData.IsRowApprover;
if (!isRowApprover && (columnDataField == ‘StatusCode’ || columnDataField == ‘RejectionTypeID’)) {
$(“#treeGrid”).jqxTreeGrid(‘endUpdate’);
}
}
}); -
AuthorPosts
You must be logged in to reply to this topic.