This is a migrated thread and some comments may be shown as answers.

Grid inCell editing: disabling conditional

4 Answers 1359 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ale
Top achievements
Rank 1
Ale asked on 07 Apr 2014, 12:05 PM
Hello, I have this grid:

@(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

Sort by
0
Alexander Popov
Telerik team
answered on 09 Apr 2014, 08:56 AM
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
 

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.

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
Alexander Popov
Telerik team
answered on 24 Oct 2014, 08:43 AM
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
 

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]);
                
           }
       }
I found my nextCell and only set  grid.current(nextCell) and grid.editCell(nextCell[0]).
It worked.

Thanks,

Tiago Dresch
Tags
Grid
Asked by
Ale
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Tiago
Top achievements
Rank 2
Share this question
or