Grid setOptions sortable = false clear header template UNEXPECTEDLY

2 posts, 1 answers
  1. Chris
    Chris avatar
    116 posts
    Member since:
    Oct 2015

    Posted 30 Jan 2018 Link to this post

    HI

    I met a problem about Grid Sortable : 

      Grid setOptions sortable = false clear header template UNEXPECTEDLY.

    What's going on ?? Why header template lost ? 
    How to avoid this situation or 
    how to disable sortable temporary and header template will not be cleared.

    Sample Code : 


      View
                    columns.Bound(c => c.Column1)
                      .HeaderTemplate
                      (
                        @<text>
                    
                        <input type='number' class='k-textbox' onfocus="class1.focusAllDays({ element: this })" style='width: 50px; font-size: small;' />

                        </text>
                      )
                      .Width(280);


      Javascript

        class1 : 

        focusAllDays: function(e)
        {
          var grid = get your grid;
          //
          grid.setOptions({  sortable: false });
        },


    Best regards

    Chris



     

     

     

  2. Answer
    Stefan
    Admin
    Stefan avatar
    2880 posts

    Posted 01 Feb 2018 Link to this post

    Hello, Chris,

    The issue occurs because the header template is rendered on the server and after the setOptions method is used the template is lost on the client.

    We have an example how this can be resolved for the Toolbar template, but the logic is similar for the header:

    https://docs.telerik.com/aspnet-mvc/helpers/grid/how-to/state/grid-preserve-server-toolbar-template-after-set-options

    I hope this is helpful.

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top