Re-rendering column in grid after data has been updated
I am trying to use a DropDownList to filter a column. The current example in the documentation is not working for me:https://ej2.syncfusion.com/vue/documentation/grid/filtering/?no-cache=1#filter-bar-template-with-custom-component
How can I re-render a column in a grid after the data has been updated?
SIGN IN To post a reply.
3 Replies
TS
Thavasianand Sankaranarayanan
Syncfusion Team
May 3, 2019 11:14 AM UTC
Hi Emily,
Greetings from Syncfusion.
Query: I am trying to use a DropDownList to filter a column. The current example in the documentation is not working for me:https://ej2.syncfusion.com/vue/documentation/grid/filtering/?no-cache=1#filter-bar-template-with-custom-component How can I re-render a column in a grid after the data has been updated?
Here, we have created a sample with filterBarTemplate with custom component. Please find the below code example and sample for your reference.
[code example]
|
. . .
new Vue({
el: '#app',
template: `
<div id="app">
<ejs-grid id="Grid" ref="grid" :dataSource="data" :created=created :allowFiltering='true'>
<e-columns>
<e-column field='OrderID' :allowFiltering='false' headerText='Order ID' textAlign='Right' width=100></e-column>
<e-column field='CustomerID' headerText='Employee ID' :template='cTemplate' :filterBarTemplate='templateOptions' width=120></e-column>
<e-column field='ShipCity' headerText='Ship City' width=100></e-column>
</e-columns>
</ejs-grid>
</div>
`,
data() {
return {
...
templateOptions: {
create: function (args) {
elem = document.createElement('input');
return elem;
},
write: function (args) {
dObj = new DropDownList({
dataSource: data,
fields: { text: "CustomerID" },
change: function (args) {
var selVal = args.value;
var grid = document.getElementById('Grid').ej2_instances[0];
grid.filterByColumn("CustomerID", "equal", selVal);
}
});
dObj.appendTo(elem);
},
}
};
},
...
}); |
Sample Link: https://plnkr.co/edit/MHbnNSoVNKyqnP1BhM7N?p=preview
Please get back to us if you need further assistance.
Regards,
Thavasianand S.
EN
Emily Nobles
May 6, 2019 01:59 PM UTC
Thank you for responding to my question. In our page, we are actually loading the data from an ajax call. When the ajax call completes we update the data on the grid.
Attachment: Code_7fd52e19.zip
Attachment: Code_7fd52e19.zip
TS
Thavasianand Sankaranarayanan
Syncfusion Team
May 7, 2019 12:36 PM UTC
Hi Emily,
We have also modified our sample by using EJ2-DataManager to provide the data source to the Grid and DropDownList. But we have not faced any issues after the modification. So we have attached the modified sample in the below link for your reference,
Also, we need some clarification in your requirement. So please share the following details to us. This will help us to provide the solution as early as possible.
- In your first update you have asked this query “How can I re-render a column in a grid after the data has been updated?”. So please share the details about when you want to re-render the Grid columns (i.e after update the Grid data source or after update the dropdownlist data source)?
- If your requirement is only re-render the column, then we suggest to use refreshColumns method of the Grid to achieve this requirement. Please ensure whether your issue getting resolved or not after using the refreshColumns method.
- Please share your exact issue what you have faced in your project.
Documentation link for refreshColumns: https://ej2.syncfusion.com/documentation/api/grid/#refreshcolumns
Regards,
Thavasianand S.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
EN Emily Nobles
- May 2, 2019 04:47 PM UTC
- May 7, 2019 12:36 PM UTC