Exception occur when click a row in data grid if both :enableVirtualization='true' and :frozenColumns=2 are set up

Hi,

Since there are over 100 columns in data grid, we set up :frozenColumns=3 to make sure first three columns always be visible.
After we set up  dataSource to the data list we get from server, it shows correctly, then we click a row, an exception occur from console in google developer tools.

If we scroll the grid up and down for several times, and click a row, again, it maybe work fine, the row can be selected.
If we don't set up frozenColumns or :enableVirtualization='true' at same time, it works very well. it looks like there are some issues when frozenColumns and :enableVirtualization='true' set up at same time, I attach code and what we got from google developer tools, the selected row uid is "grid-row21", but current show rows uid is from "grid-row71", please tell us how to fix this?

(1) Code 
   <ejs-grid ref='gmapoverviewgrid' 
                width='100%' 
                :height="gridheight" 
                rowHeight=30                
                :allowFiltering='false' 
                :allowSorting='true'        
                :allowResizing='true' 
                :enableVirtualization='true' 
                :frozenColumns=2                             

                .....

                :columns = datasheetColumns
                :dataSource="mapItemList" >                
            </ejs-grid>


export default {
       ...
        data(){
            return {                
                mapItemList: [],
                datasheetColumns: []
            };
        },
   ...
}

After we get the record array from the server, we assign it to mapItemList, it can show correctly,


(2) Error 
 when click a row, get an exception, below is detail we get from google developer tools
   (2-1) error in selection selectRow


 (2-2) error in selectRow


(3-3) error in getRowObjectFromUID
  select row uid="grid-row21" which is no tin current row list, I don't know how to set up to prevent this happen.



Thanks,



21 Replies 1 reply marked as answer

AG Ajith Govarthan Syncfusion Team July 21, 2020 03:39 PM UTC

Hi CZ, 

Thanks for contacting Syncfusion support. 

Query:  Exception occur when click a row in data grid if both :enableVirtualization='true' and :frozenColumns=2 are set up 
 
We have checked your one of the forum 156063 and in that you have mentioned the same query. So we have suspect that you have tried to use custom binding in your sample. 
 
And you have used the actionBegin event to fetch data for the grid component and this is not proper method to fetch data and set the data to the Grid component. In our EJ2 Grid component we have event called dataStateChange using that you can bind custom data to the grid component. 
 
And based on the attached code example we have prepared sample and found everything works fine at our end. And there are no script errors while selecting rows. For your convenience we have attached the sample so please refer them for your reference. 


App.vue 

<ejs-grid ref="grid" :dataSource='data' height="400" width="800" :frozenColumns="2"  :enableVirtualization="true" 
:dataStateChange='dataStateChange' :rowSelected="rowSelected" :allowSorting="true" :rowHeight="30" :allowResizing="true"
<e-columns> 
<e-column field= "OrderID" headerText="Order ID" width="130" textAlign='Right' ></e-column> 
<e-column field= "CustomerID" headerText="CustomerID" width="130" textAlign='Right' ></e-column> 
<e-column field= "Freight" headerText="Freight" width="130" textAlign='Right' ></e-column> 
<e-column field= "ShipCountry" headerText="Country" width="130" textAlign='Right' ></e-column> 
<e-column field= "ShipCity" headerText="City" width="130" textAlign='Right' ></e-column> 
<e-column field= "ShipAddress" headerText="Address" width="130" textAlign='Right' ></e-column> 

</e-columns> 
</ejs-grid> 
dataStateChange: function (state) { 
if (state.action && (state.action.requestType === "filterchoicerequest" || state.action.requestType ==="filtersearchbegin")) { 
this.orderService.execute(state).then((e) => { 
state.dataSource(e.result); 
}); 
} else { 
this.orderService.execute(state).then(( gridData ) => this.data = gridData ); 



Documentation links: 

if the above solution doesn’t meet your solution then please share the below details to find the root cause of the issue. 

  1. Share the complete grid code example.
  2. Share the data structure bind to the grid.
  3. If possible share the video demonstration of the issue.
  4. Share the Syncfusion package version.

Regards, 
Ajith G.  



 



CZ CZ July 21, 2020 10:47 PM UTC

Hi Ajith,

Thank you for your help.

In order to make it simple, in our new test, we get all the data from the server once in create event and binding the return data to the grid dataSource(we don't use actionBegin event to fetch data at all), so in the new test, it is nothing related with actionBegin.

it must be caused by frozenColumns and :enableVirtualization='true' set up at same time, can you give me a sample with frozenColumns and :enableVirtualization='true' which working very well?

Thanks



MS Manivel Sellamuthu Syncfusion Team July 22, 2020 03:51 PM UTC

Hi CZ, 

Thanks for your update. 

Asper your requirement ,we have  prepared a simple sample enabled with frozen columns and virtualization. Please find the below sample for more information. 


Please let us know, if you need further assistance. 

Regards, 
Manivel 



CZ CZ July 22, 2020 06:24 PM UTC

Thanks,



MS Manivel Sellamuthu Syncfusion Team July 23, 2020 05:41 AM UTC

Hi CZ, 

Thanks for your update. 

Please let us know, if you need further assistance. 

Regards, 
Manivel 



CZ CZ July 27, 2020 07:36 PM UTC

Hi Manivel,


In our project, the data grid columns are large and dynamically, so we get its setting from the database and binding its to columns property, like :columns = columns,all these columns are readonly, but we need to add a new column as first column which is checked box and editable, please let us how can we implement this?

Just like below picture,  column Id, Name(english), Name, ...are dynamically set up in database, we can bind these columns by vue grid columns property, but visible column different from other columns, it is editable, it is a checkbox, not set up in database, we check and unchecked it,  after its status change, we need to get its status change event and do the relative work. 




Thanks,





RS Rajapandiyan Settu Syncfusion Team July 28, 2020 11:29 AM UTC

Hi CZ, 

Thanks for your update. 

Query :  visible column different from other columns, it is editable, it is a checkbox, not set up in database, we check and unchecked it,  after its status change, we need to get its status change event and do the relative work.  

We have analyzed your query and understood that you want to need one extra column in the grid which is not in your column database. You can achieve your requirement by unshifting one column to the grid columns in the load event. We have rendered checkbox in that column by using columnTemplate feature. please refer the below code example and sample for more information. 


<template> 
  <div id="app"> 
    <ejs-grid 
      id="Grid" 
      ref="grid" 
      height="400" 
      :dataSource="data" 
      :frozenColumns="3" 
      :enableVirtualization="true" 
      :columns="columns" 
      :load="load" 
    ></ejs-grid> 
  </div> 
</template> 

<script> 
import Vue from "vue"; 
import { GridPlugin, Freeze, VirtualScroll } from "@syncfusion/ej2-vue-grids"; 
import { DataUtil } from "@syncfusion/ej2-data"; 
import { data } from "./datasource"; 
import { CheckBoxPlugin } from "@syncfusion/ej2-vue-buttons"; 
import { enableRipple } from "@syncfusion/ej2-base"; 

enableRipple(true); 
Vue.use(GridPlugin); 
Vue.use(CheckBoxPlugin); 

export default { 
  data() { 
    return { 
      data: DataUtil.parse.parseJson(data), 
      columns: [ 
        { field: "OrderID", width: "140" }, 
        { field: "CustomerID", width: "140" }, 
        { field: "OrderDate", format: "yMd", width: "140" }, 
        { field: "Freight", format: "C2", width: "140" }, 
        { field: "ShipCountry", width: "140" } 
      ] 
    }; 
    e; 
  }, 
  provide: { 
    grid: [VirtualScroll, Freeze] 
  }, 
  methods: { 
    load: function(args) { 
// add the custom column if it not present in the grid column 
      if (!( this.$refs.grid.$el.ej2_instances[0].columns[0].field ===   "customcolumn" )){ 
// add a custom column into the grid columns 
        this.$refs.grid.$el.ej2_instances[0].columns.unshift({ 
          field: "customcolumn", 
          headerText: "Visible", 
          width: "90", 
          template: this.gridSearchTemplate // bind the template for that column 
        }); 
      } 
    }, 
    gridSearchTemplate: function() { 
      return { 
        template: Vue.component("GridSearchTemplate", { 
          template: ` 
<div ><ejs-checkbox  :change="checkboxChange"></ejs-checkbox> // render a checkbox component 
</div>`, 
          data() { 
            return {}; 
          }, 
          methods: { 
            checkboxChange: function(args) { 
// this event will be triggered when checkbox state changed 
// here you can do your action 
            } 
          } 
        }) 
      }; 
    } 
  } 
}; 
</script> 





Please get back to us if you need further assistance on this. 

Regards, 
Rajapandiyan S

Marked as answer

CZ CZ July 29, 2020 12:10 AM UTC

Thanks,
CZ


MS Manivel Sellamuthu Syncfusion Team July 29, 2020 07:30 AM UTC

Hi CZ,  

Thanks for your update.  

Please let us know, if you need further assistance.  

Regards,  
Manivel 



CZ CZ August 3, 2020 12:00 AM UTC

Hi Manivel ,

1. The sample you provide is what we want to do, we are working on this function in our project right now.

We get error in our project when we implement this function.  so we download the sample you provide and try to make it work.  we install package by "npm install "  and run it, and we get below error,


2. If it is possible to refresh a special row?
  In our application, when click a row in a grid, we need to update this row value and refresh its display in data grid,  we implement this by binding to "recordClick" and modify this row data and re-bind grid dataSource, it works. but if we have selected a row, after re-bind, the selected row will be un-selected,  we have to write extra code,
 We wonder if we can only refresh this row display without re-bind grid dataSource ?

Thanks,

CZ



MS Manivel Sellamuthu Syncfusion Team August 3, 2020 06:23 AM UTC

Hi CZ, 

Thanks for your update. 

Query:1We get error in our project when we implement this function.  so we download the sample you provide and try to make it work.  we install package by "npm install "  and run it, and we get below error, 
 
We have analyzed the reported issue. We suspect that you have created the Vue sample by using the Runtime-only build. This build will contain only the basic services. Hence the template service could not be handled with this build. So we suggest you to use the compiler build or just configure by adding the below codes in the “vue.config.js” file to overcome the error you are facing and create a template sample in Grid. Please refer the below code example ,sample and documentation for more information. 

vue.config.js 
 
module.exports = { 
    configureWebpack: { 
    resolve: { 
    alias: { 
      'vue$': 'vue/dist/vue.esm.js' // 'vue/dist/vue.common.js' for webpack 1 
   } 
  } 
  } 


Documentation Link: 



Query: 2. If it is possible to refresh a special row? 
 
Yes. You can change data for particular row and refresh that row only instead of refreshing Grid. You can use setRowData method Updates and refresh the particular row values in the UI level and updateRow method Updates and refresh the particular row values in the UI and grid DataSource. 


Note: Since you want to refresh the particular row in the recordClick event of the Grid, we suggest you to invoke the above method in a certain time delay to avoid collapse in the UI. 

Please let us know, if you need further assistance. 

Regards, 
Manivel 



CZ CZ August 3, 2020 09:27 PM UTC

Manivel,

Thank you for your help.

Query:1We get error in our project when we implement this function.  so we download the sample you provide and try to make it work.  we install package by "npm install "  and run it, and we get below error

After we copy vue.config.js from our project to this demo project, it works in demo project, we make a little change to bind standard html5 check box in template.

But copy the code to our project, it doesn't work in our project, we check the @syncfusion/ej2-vue-grids version on both project and event binding to same columns in demo project, we always get same error,

(1) code:  -- this code works in demo project

load: function(args) {                
         var columns = this.$refs.gmapoverviewgrid.$el.ej2_instances[0].columns;
         if (columns.length > 0 &&  columns[0].field != "customcolumn" ) {
             columns.unshift({
                        field: "customcolumn",
                        headerText: "Visible",
                        width: "90",
                        template: this.gridSearchTemplate
                    });
                }
            },
            gridSearchTemplate: function() {
                return {
                    template: Vue.component("GridSearchTemplate", {
                        template: `<div ><input type="checkbox"  :change="checkboxChange"/></div>`,
                        data() {
                            return {};
                        },
                        methods: {
                            checkboxChange: function(args) {
                            alert("checkbox state changed");
                            }
                        }
                    })
                };
   .....

(2) Error we get in google developer tools



(3) We trace in template.js
  


In 71, str is function, not the template content.

We try several hours and could not find out the reason what is wrong.

Query: 2. If it is possible to refresh a special row? 

 If we use below code to bind the current page data, we can refresh whole page, the update value can be refresh in GUI(showingmapItemPageInfo is dataSource we bind)

 recordClick:function(args) {                 
    args.rowData.Show = !args.rowData.Show;
    this.$nextTick(() => {
         var pageinfo = {
           count: this.showingmapItemPageInfo.count,
             result: this.showingmapItemPageInfo.result
         };
         this.showingmapItemPageInfo = pageinfo;
    });    
 }

but if we call updateRow , the update value can not be refresh in GUI, below is the code

recordClick:function(args) {                 
    args.rowData.Show = !args.rowData.Show;
    this.$nextTick(() => {
         this.$refs.gmapoverviewgrid.updateRow(args.rowIndex,args.rowData);
    });    
}

Thanks
cz






MS Manivel Sellamuthu Syncfusion Team August 4, 2020 07:50 AM UTC

Hi Zhao, 

Thanks for your update. 

Query: copy the code to our project, it doesn't work in our project, we check the @syncfusion/ej2-vue-grids version on both project and event binding to same columns in demo project, we always get same error, In 71, str is function, not the template content. 
We try several hours and could not find out the reason what is wrong 

We have validated the provided details and we suspect that the problem is because of duplicate packages might be installed in your ‘@syncfusion’ folder of ‘node_modules’ or the base packages not installed properly. So we suggest you to follow the below steps to solve the problem. 

1.           Delete package.lock.json file from your application. 
2.           Remove the @syncfusion  package folder from the node_modules
3.           Use latest and same version for components(Grid, etc) in package.json file. 
4.           Then install the new packages. 


Query: if we call updateRow , the update value can not be refresh in GUI, below is the code 

From this query, we suspect that you have not enabled the editSettings and primary key column of the Grid. Please ensure them in the sample. 

Please let us know, if you need further assistance. 

Regards, 
Manivel 



CZ CZ August 4, 2020 06:02 PM UTC

Hi Regards,

Thank you for your help.

Query: copy the code to our project, it doesn't work in our project, we check the @syncfusion/ej2-vue-grids version on both project and event binding to same columns in demo project, we always get same error, In 71, str is function, not the template content. 
We try several hours and could not find out the reason what is wrong 

We have followed your instruction to to refresh package step by step,  we make @syncfusion/ej2-vue-grids same version, reboot up machine and clean google chrome cache, we are afraid if it is related with load event, so we try to bind template in columns directly like below

     <ejs-grid :dataSource="data" height=310>
            <e-columns>
                <e-column headerText='Employee Image' width='150' textAlign='Center' :template='cTemplate'></e-column>
               ...
            </e-columns>
        </ejs-grid>

No Matter what step we try, we still get same error, we are not figure out what is wrong, only different in our project we have much more components than in demo project, do you have any clue?

Query: recordClick event will not fire when click on cells of locked-columns, how to make it make its event fire? 



Thanks,
CZ
:recordClick='recordClick'




MS Manivel Sellamuthu Syncfusion Team August 5, 2020 10:45 AM UTC

Hi Zhao, 

Thanks for your update. 

Query: No Matter what step we try, we still get same error, we are not figure out what is wrong, only different in our project we have much more components than in demo project, do you have any clue? 
 
The reported is issue is a known issue in our end and we are sure that issue occurred due to duplicate packages. So Please follow the below steps and id you still faced the issue, Please share the issue reproducible sample, if possible or steps to replicate the reported issue. 

  1. Delete the node_modules folder and package.lock.json file from your project
  2. Then install the packages again by following the provided documentation


Query: recordClick event will not fire when click on cells of locked-columns, how to make it make its event fire? 
 
We have checked the reported issue at our end. But it is working fine at our end. Please refer the below sample for your reference. 
 

If you still face the issue then please share the below details to find the root cause of the issue. 

  1. Share the complete grid code example.
  2. Share the video demonstration of the reported issue.
  3. If possible please try to reproduce the reported issue in the given sample.

Regards, 
Manivel 



CZ CZ August 5, 2020 03:29 PM UTC

Hi Manivel,

Thank you for your professional help.

Query: No Matter what step we try, we still get same error, we are not figure out what is wrong, only different in our project we have much more components than in demo project, do you have any clue? 
 
 We will make a video record to show our steps and issue if there are sill issue after we make 

Query: recordClick event will not fire when click on cells of locked-columns, how to make it make its event fire? 
 
We test carefully, it is related with the code in recordClick.

if we remark this.showingmapItemPageInfo = pageinfo; recordClick will fire each time when click on the cells of locked-columns, 
but if with this code, it will fire only one time, and not any error on console.
 
recordClick:function(args) {                 
    args.rowData.Show = !args.rowData.Show;
    this.$nextTick(() => {
         var pageinfo = {
           count: this.showingmapItemPageInfo.count,
             result: this.showingmapItemPageInfo.result
         };
         this.showingmapItemPageInfo = pageinfo;
    });    
 }

Thanks



MS Manivel Sellamuthu Syncfusion Team August 6, 2020 06:10 AM UTC

  
Hi Zhao, 

Thanks for your update. 

Query: We will make a video record to show our steps and issue if there are still issue after we make. 
 
We will wait to hear from you. 

Query: We test carefully, it is related with the code in recordClick. 

We are glad that you have found the issue on your own. So we suggest you to remove or modify your code inside the record click fire each time. 

Please let us know, if you need further assistance. 

Regards, 
Manivel 



CZ CZ September 2, 2020 08:48 PM UTC

Hi Manivel,

In our project, we are using data grid, this grid data is not editable, but every time we click one row, the first cell  "Show" value need to switch between "True" and "False", we implement this by

 :recordClick='recordClick'
 :dataSource="showingmapItemPageInfo" />

recordClick:function(args) {                 
    args.rowData.Show = !args.rowData.Show;
    this.$nextTick(() => {
         var pageinfo = {
           count: this.showingmapItemPageInfo.count,
             result: this.showingmapItemPageInfo.result
         };
         this.showingmapItemPageInfo = pageinfo;
    });    
 }

We have to refresh datasource to display updated Show field value,  but recordDoubleClick will not fire after we add above code in recordClick event.
I check there are a updateCell method, but the data grid need to set up to editable

I don't know if there are any way we can update a cell value in recordClick event without setup data grid editable  and the recordDocubleClick event can also fire, can you provide us an example anyway? 

Thanks,
CZ



MS Manivel Sellamuthu Syncfusion Team September 4, 2020 01:30 PM UTC

Hi Zhao, 

Thanks for your update. 

Based on your requirement, we can understand that you want to change the value of the rowData while clicking the record without enabling Editing. For this requirement you can use the setRowData method of the Grid. 

We would like to inform you that setRowData method requires primaryKeyColumn to work properly. Please refer the below code  example and sample for more information. 

<template> 
  <div id="app"> 
    <ejs-grid 
      id="Grid" 
      ref="grid" 
      height="400" 
      :dataSource="data" 
      :frozenColumns="3" 
      :enableVirtualization="true" 
      :recordClick="recordClick" 
      :columns="columns" 
    ></ejs-grid> 
  </div> 
</template> 
 
<script> 
import Vue from "vue"; 
import { GridPluginFreezeVirtualScroll } from "@syncfusion/ej2-vue-grids"; 
import { DataUtil } from "@syncfusion/ej2-data"; 
import { data } from "./datasource"; 
import { CheckBoxPlugin } from "@syncfusion/ej2-vue-buttons"; 
import { enableRipple } from "@syncfusion/ej2-base"; 
 
enableRipple(true); 
Vue.use(GridPlugin); 
Vue.use(CheckBoxPlugin); 
 
export default { 
  data() { 
    return { 
      data: DataUtil.parse.parseJson(data), 
      columns: [ 
        { field: "OrderID"isPrimaryKey: true, width: "140" }, 
        { field: "CustomerID", width: "140" }, 
        { field: "OrderDate", format: "yMd", width: "140" }, 
        { field: "Freight", format: "C2", width: "140" }, 
        { field: "ShipCountry", width: "140" } 
      ] 
    }; 
  }, 
  provide: { 
    grid: [VirtualScrollFreeze] 
  }, 
  methods: { 
    recordClickfunction(args) { 
      console.log(args); 
      // here we are changing the ‘CustomerID’ column’s value 
      args.rowData.CustomerID = "changed"; 
      setTimeout((e)=>{ 
// here invoking the setRowData method of the Grid 
             this.$refs.grid.ej2Instances.setRowData(args.rowData["OrderID"], args.rowData); 
      },) 
    } 
  } 
}; 
</script> 



Please let us know, if you need further assistance. 

Regards, 
Manivel 



CZ CZ September 7, 2020 04:05 PM UTC

Hi Manivel,

It works.

Thanks,

CZ


MS Manivel Sellamuthu Syncfusion Team September 8, 2020 05:08 AM UTC

Hi Zhao,  

Thanks for your update.  

We are happy to hear that the problem has been resolved by the provided solution.  

Please let us know, if you need further assistance.  

Regards,  
Manivel 


Loader.
Up arrow icon