title: kendo ui grid edit button not working after loading persisting state
body: <p>I am using Teleric kendo UI grid. I am using a database table to store grid options to save (persist) the grid state (column ordering, no of column default viewable etc) . It save option for every user, when the user login agin the state will automatically loded using an ajax call. Everything work fine</p>
  
  <p>But the problem is that Edit button not working after loading saved state. 
  Please help.</p>
  
  <p>thanks in advance</p>
  
  <pre><code>&lt;div class="row"&gt;
  &lt;div class="col-md-12 col-sm-12 col-xs-12"&gt;
  &lt;?php echo $this-&gt;session-&gt;flashdata('message');?&gt; 
  &lt;div class="panel panel-default"&gt;
  &lt;div class="panel-heading clearfix"&gt;
  
  &lt;div class="panel-body"&gt;
  
  &lt;?php
  $transport = new \Kendo\Data\DataSourceTransport();
  
  $read = new \Kendo\Data\DataSourceTransportRead();
  
  $read-&gt;url(site_url('task/jsonMData'))
       -&gt;contentType('application/json')
       -&gt;type('POST');
  
  $transport-&gt;read($read)
            -&gt;parameterMap('function(data) {
                return kendo.stringify(data);
            }');
  
  $model = new \Kendo\Data\DataSourceSchemaModel();
  
  $id = new \Kendo\Data\DataSourceSchemaModelField('id');
  $id-&gt;type('number');
  
  $Name = new \Kendo\Data\DataSourceSchemaModelField('name');
  $Name-&gt;type('string');
  
  $Address = new \Kendo\Data\DataSourceSchemaModelField('address');
  $Address-&gt;type('string');
  
  
  
  $model-&gt;addField($id)
          -&gt;addField($Name)
          -&gt;addField($Address);
  
  
  $schema = new \Kendo\Data\DataSourceSchema();
  $schema-&gt;data('data')
         -&gt;model($model)
         -&gt;total('total');
  
  $dataSource = new \Kendo\Data\DataSource();
  
  $dataSource-&gt;transport($transport)
             -&gt;pageSize(500)
             -&gt;schema($schema)
             -&gt;serverFiltering(true)
             -&gt;serverSorting(true)
             -&gt;serverGrouping(false)
             -&gt;serverPaging(true);
  
  $grid = new \Kendo\UI\Grid('grid');
  
  $idField = new \Kendo\UI\GridColumn();
  $idField-&gt;field('id')
              -&gt;locked(false)
              -&gt;width(60)
              -&gt;hidden(true)
              -&gt;title('ID');
  
  
  $nameField = new \Kendo\UI\GridColumn();
  $nameField-&gt;field('name')
            -&gt;width(100)
            -&gt;locked(false)
            -&gt;hidden(true)
            -&gt;title('Name');
  $addressField = new \Kendo\UI\GridColumn();
  $addressField-&gt;field('address')
            -&gt;width(200)
            -&gt;locked(false)
            -&gt;hidden(true)
            -&gt;title('Address');
  
  
  
  $command = new \Kendo\UI\GridColumnCommandItem();
  $command-&gt;click('commandClick')
          -&gt;text('Edit');
  
  $commandColumn = new \Kendo\UI\GridColumn();
  $commandColumn-&gt;addCommandItem($command)
          -&gt;title('Edit')
          -&gt;width(125);
  
  $excel = new \Kendo\UI\GridExcel();
  $excel-&gt;fileName(' Task Export.xlsx')
        -&gt;filterable(true)
        -&gt;proxyURL('task/saveToExcel');
  
  $grid-&gt;addColumn($id,
  $name, $commandColumn)
       -&gt;height(500)
       -&gt;scrollable(true)
       -&gt;editable('popup')
       -&gt;dataSource($dataSource)
       -&gt;resizable(true)
       -&gt;reorderable(true)
       -&gt;sortable(true)
       -&gt;filterable(true)
       -&gt;columnMenu(true)
       -&gt;pageable(true)
       -&gt;addToolbarItem(new \Kendo\UI\GridToolbarItem('excel'))
       -&gt;excel($excel);
  
  $grid-&gt;columnHide('function(e) { saveGridState(); }');
  $grid-&gt;columnShow('function(e) { saveGridState(); }');
  
   echo $grid-&gt;render();
  ?&gt;
  
  &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
  
  &lt;div style="display:none;"&gt;
  &lt;a href="#" id="hidden-link" class="fancybox fancybox.iframe"&gt;Click&lt;/a&gt;
  &lt;input type="hidden" name="rowIndex" id="rowIndex" value="-1" /&gt;
  &lt;input type="hidden" name="taskId" id="taskId" value="0" /&gt;
  &lt;/div&gt;
  &lt;!--to support excel import --&gt;
  &lt;script&gt;
  function commandClick(e) {
  
  
          e.preventDefault();
          var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
          console.log(dataItem);
  
          var grid = $(e.currentTarget).closest("tr");
          var row = grid.select();
  
          var rowIndex = row.index();
  
          var j = $('#hidden-link');
          if(j)
          {
            $('#rowIndex').val(rowIndex);
            $('#taskId').val(dataItem.id);
            j.attr('href','&lt;?php echo base_url()."task/edit";?&gt;/'+dataItem.id)
            j.click();
          }
      }
  &lt;/script&gt;   
  &lt;script type="text/javascript"&gt;
  $(document).ready(function() {
      $(".fancybox").fancybox({
          'afterClose':function () {
              var rowIdx = $('#rowIndex').val();
              var taskId = $('#taskId').val();
              if(taskId != 0 &amp;&amp; rowIdx &gt;= 0)
              {
                  userData = 'id='+taskId;
                  $.ajax({
                      url: "&lt;?php echo site_url('task/getTaskById');?&gt;",
                      type: "post",
                      data: userData,
                      dataType: "json",
                      success: function(data){
                          var firstRowItem = $('#grid').data().kendoGrid.dataSource.data()[rowIdx];
  
                          firstRowItem.set('Name',data.name);
                          firstRowItem.set('Plant',data.address);
  
  
                      },
                      async:false,
                      error:function(){
  
                          alert('There is error while submit');
                      }
  
                  });
              }
          },
        });
  
  
           var grid = $("#grid").data("kendoGrid");
           userData = "type='m'";
           $.ajax({
          url: "&lt;?php echo site_url('task/getGridSavedState');?&gt;",
          type: "post",
                  data:{type:'m'},
                 // contentType:'application/json',
          dataType: "json",
          success: function(data){
                      if(data.columns)
                      {
                       options=data;
                       grid.setOptions(options);
                      }
                  },
                  error:function(){
  
              console.log("Error loding save grid state");
          }
          });
  
  });
  function saveGridState()
  {
      var grid = $("#grid").data("kendoGrid");
      gridOptions=grid.getOptions();
      var request=kendo.stringify({gridOptions : gridOptions,type:'m'});
  
      $.ajax({
          url: "&lt;?php echo site_url('task/saveGridState');?&gt;",
          type: "post",
                  contentType:'application/json',
          data: request,
          dataType: "json",
          success: function(data){
                      console.log("stated saved");
                  },
                  error:function(){
  
              console.log("Error in stated saved")
          }
          });
  
  }
  
  &lt;/script&gt;
  </code></pre>