Hello, I have this grid:
I want to disable the "DocAmount" cell if the "LForId" have a specific value, and everytime I change the value I want to check and enable\disable the cell.
How can I do that...
@(Html.Kendo().Grid(Model.ListiniRighe)
.Name(
"ListiniRighe"
)
.Columns(columns =>
{
columns.ForeignKey(l => l.LForId, listFor,
"LForId"
,
"Formula"
);
columns.Bound(l => l.DocAmount).Format(
"{0:c}"
);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(ed => ed.Mode(GridEditMode.InCell))
)
I want to disable the "DocAmount" cell if the "LForId" have a specific value, and everytime I change the value I want to check and enable\disable the cell.
How can I do that...
4 Answers, 1 is accepted
0
Hello Ale,
I would recommend subscribing to the Grid's edit event. Once the event is triggered check if the currently edited cell is DocAmount and what is the value of the LForId. If the criteria is met use the Grid's closeCell method, thus emulating a disabled cell. Here is a small example illustrating similar behavior.
Regards,
Alexander Popov
Telerik
I would recommend subscribing to the Grid's edit event. Once the event is triggered check if the currently edited cell is DocAmount and what is the value of the LForId. If the criteria is met use the Grid's closeCell method, thus emulating a disabled cell. Here is a small example illustrating similar behavior.
Regards,
Alexander Popov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Tiago
Top achievements
Rank 2
answered on 22 Oct 2014, 12:39 PM
Hello Alexander,
In your Sample , please set navigatable : true.
When the cell is closed you will see that the focus is out of the grid, but i need select the next cell to edit.
I'm trying get the next cell and set it to editing, but this is not working.
How can i do it?
Thanks,
Tiago Dresch.
In your Sample , please set navigatable : true.
When the cell is closed you will see that the focus is out of the grid, but i need select the next cell to edit.
function onEdit(e) {
var grid = $(
'#GridPlanejamento'
).data(
'kendoGrid'
);
var indexCell = $(
"#GridPlanejamento_active_cell"
)[0].cellIndex;
var isCanceled = verifyBlokCell(e.model, indexCell);
var cell = $(
"#GridPlanejamento_active_cell"
)[0];
if
(isCanceled) {
grid.closeCell(cell);
var nextCell =
this
.tbody.find(
">tr[data-uid='"
+ e.model.uid +
"'] td:eq("
+ indexCell +
")"
).next()[0];
grid.editCell(nextCell);
}
}
I'm trying get the next cell and set it to editing, but this is not working.
How can i do it?
Thanks,
Tiago Dresch.
0
Hello Tiago,
Skipping non-editable cells is not supported out of the box, however it could be achieved using a custom solution. I would suggest checking this forum thread, where similar topic is discussed.
Regards,
Alexander Popov
Telerik
Skipping non-editable cells is not supported out of the box, however it could be achieved using a custom solution. I would suggest checking this forum thread, where similar topic is discussed.
Regards,
Alexander Popov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Tiago
Top achievements
Rank 2
answered on 24 Oct 2014, 04:17 PM
function onEdit(e) {
var grid = $(
'#GridPlanejamento'
).data(
'kendoGrid'
);
var cell = $(
"#GridPlanejamento_active_cell"
)[0];
var indexCell = $(
"#GridPlanejamento_active_cell"
)[0].cellIndex;
var isCanceled = verifyBlokCell(e.model, indexCell);
if
(isCanceled) {
var row = $(
"#GridPlanejamento"
).find(
"[data-uid='"
+ e.model.uid +
"']"
);
var rowIndex = row.index();
var nextCell = $(
".k-grid-content"
).find(
"table"
).find(
"tbody"
).find(
"tr:eq("
+ rowIndex +
")"
).find(
"td:eq("
+ indexCell +
")"
).next();
grid.closeCell(cell);
grid.current(nextCell);
grid.editCell(nextCell[0]);
}
}
It worked.
Thanks,
Tiago Dresch