HI,
I have a igGrid with one requirement. In that Grid i have a two columns one is checkbox and another one is Textbox,
if checkbox is checked then next field(Textfield) should be editable and it is a mandatory field.
Thanks,
Ashok.
Hello Ashock,
Please let me know if you need any further assistance with this matter.
Hello Ashok,
Attached you will find a sample project using MVC. The required functionality is achieved using the same approach with handling editCellStarting event.
Please have a look at the provided sample and let me know if you have any additional questions afterwards.
Thanks for your reply.
I have the code on MVC. Can you tell me how to add the above mentioned functionality on ColumnUpdatingSetting method of GridUpdating function.
Thank you for posting in our community.
What I can suggest for achieving your requirement is handling editCellStarting event. In this event you could check what is the value of the checkbox column and if false cancel editing. Please keep in mind that when the edit mode is set to "row" this event is going to be fired for every cell in this row. In order to handle this event only for the column that you are looking for you will have to check the column key of event target. Regarding the validation what I can propose is initially setting this columns required option to true. For example:
$("#grid").igGrid({ dataSource: data, primaryKey: "ID", renderCheckboxes : true, columns: [ {headerText: "ID", key: "ID", dataType: "number", hidden:true}, {headerText: "Name", key: "Name", dataType: "string" }, {headerText: "DisableEdit", key: "DisableEdit", dataType: "bool"} ], features: [ { name: "Updating", enableAddRow: true, editMode: "row", enableDeleteRow: true, columnSettings: [ { columnKey: "Name", required: true } ], editCellStarting: function (evt, ui) { var columnKey = ui.columnKey; var rowIndex = ui.rowID; var editColumnValue = $("#grid").igGrid("getCellValue",rowIndex, "DisableEdit" ); if(columnKey == "Name") { if(!editColumnValue) { return false; } } } }] }); });
I am also attaching a sample project illustrating mu suggestion for your reference. Please have a look at this sample and let me know if you have any additional questions regarding this matter.