Keep grid cell as input box

2 posts, 0 answers
  1. Marcus
    Marcus avatar
    6 posts
    Member since:
    Sep 2019

    Posted 08 Jan 2020 Link to this post

    Hi,

    I have an editor grid that has one editable cell. I want that cell to always be the input box (numeric text box in this case) instead of going back to a regular dirty cell after clicking out. So basically always keeping cells in edit mode.How can I achieve this? See attached image for example of what I mean.

     

  2. Tsvetomir
    Admin
    Tsvetomir avatar
    757 posts

    Posted 10 Jan 2020 Link to this post

    Hi Marcus,

    In general, you could create templates that would be always open in read mode of the grid. Add a ClientTemplate:

    columns.Bound(c=>c.Name).ClientTemplate("<input data-bind='value: Name' >");

    Within the DataBound event handler, bind the input to the respective field. It is important to point out that the name above should correspond to the field name of the column:

    function onDataBound(e){
              var rows = this.tbody.children();
              var dataItems = this.dataSource.view();
              for (var i = 0; i < dataItems.length; i++)  {
                kendo.bind(rows[i], dataItems[i]);
              }
    }

    Bear in mind that this approach might lead to a negative impact on the overall performance of the application due to the binding of the inputs to the underlying model.

     

    Best regards,
    Tsvetomir
    Progress Telerik

    Get quickly onboarded and successful with your Telerik UI for ASP.NET MVC with the dedicated Virtual Classroom technical training, available to all active customers.
Back to Top