Grid inCell editing: disabling conditional

5 posts, 0 answers
  1. Ale
    Ale avatar
    13 posts
    Member since:
    Dec 2013

    Posted 07 Apr 2014 Link to this post

    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...
  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1444 posts

    Posted 09 Apr 2014 Link to this post

    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.

     
  3. Tiago
    Tiago avatar
    8 posts
    Member since:
    Oct 2012

    Posted 22 Oct 2014 in reply to Alexander Popov Link to this post

    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.
  4. Alexander Popov
    Admin
    Alexander Popov avatar
    1444 posts

    Posted 24 Oct 2014 Link to this post

    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.

     
  5. Tiago
    Tiago avatar
    8 posts
    Member since:
    Oct 2012

    Posted 24 Oct 2014 in reply to Alexander Popov Link to this post

    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
Back to Top