Hi,
I'm working with iggrid in mvc. I have a grid with checkbox and this checkbox should be readonly if match count is > 0.
MODEL:
MatchCount
IsActive
GRID:
@Html.Infragistics().Grid(Model)
$(document).delegate("#sales-last-grid", "iggriddatarendered", function (evt, ui) {
gridRendered(evt, ui);
});
JAVASCRIPT:
gridRendered(evt, ui){
// Here I want to check the readonly status by match count. What I did is:
var grid = $("#grid");
var dataview = grid.data('igGrid').dataSource.dataView();
dataview.forEach(function (obj, index) {
if (obj.MatchCount == 0) {
???? HERE I DONT KNOW HOW TO MODIFY READONLY VALUE
}
Hello,
Thank you for the update. The igGrid can only make things read only at the column level. If you want to do it on the cell level you have to instead handle the editCellStarting or editRowStarting and cancel the event by returning false:
http://www.igniteui.com/help/api/2016.2/ui.iggridupdating#events:editCellStarting
http://www.igniteui.com/help/api/2016.2/ui.iggridupdating#events:editRowStarting
If you look at the api for the events you can see that you are provided with the rowID which you can then use to check other values in the row to see if that cell should be read only or not.
http://www.igniteui.com/help/api/2016.2/ui.iggrid#methods:getCellValue
Hi Mike,
Thank you for your reply, but that doesn't help much.
My question is:
The checkbox should be readonly if match count is > 0 mean depend on the other value of the column. And how to switch it to readonly
- NOT an entire column
- NOT only a single cell
- MAYBE a templated checkbox but how to do it?
My Grid
MatchCount Checkbox
0 readonly because MatchCount = 0
1 not readonly because MatchCount > 0
You have to check the MatchCount for each column and render the checkbox readonly or not
You will see code examples in my question and I'm waiting for a code example.
Thank you
Thank you for contacting Infragistics!
If you want to make an entire column read only/un- editable you would adjust the column settings of the Updating feature:
http://www.igniteui.com/help/api/2016.2/ui.iggridupdating#options:columnSettings.readOnly
If you want to make only a single cell or checkbox read only you would instead handle editing events or value changing events. For making a cell, row, or built in checkbox un-editable you would handle editCellStarting or editRowStarting and return false to cancel entering edit mode:
For a templated checkbox you would want to handle the valueChanging event of the templated checkbox and cancel that instead.