- Home
- Forum
- ASP.NET Core - EJ 2
- Refresh ListView with remote data
Refresh ListView with remote data
Hello,
I am using a listview with a data manager like this:
<ejs-listview id="idList" cssClass="e-list-template m-2" showHeader="false"
template="#listTemplate"
actionComplete="onListComplete">
<e-data-manager url=" /Quarter/ListItems" adaptor="UrlAdaptor">
</e-data-manager>
</ejs-listview>
I want to refresh the listview items after a UI change. For that, I call a javascript function (a piece of code I have found in your documentation):
function switchChange() {
const grid = document.getElementById("idList").ej2_instances[0];
const ajax = new ej.base.Ajax('/Quarter/ListItems', 'GET');
ajax.send();
ajax.onSuccess = function (data) {
grid.dataSource = ej.data.DataUtil.parse.parseJson(data).result;
};
}
It calls the Controller method and send back the data, but doesn't refresh the listview.
How can I simply refresh the listview with updated remote data without reloading the page?
In fact, I have the same question for the diagram and the kanban component.
Sample: https://www.syncfusion.com/downloads/support/directtrac/329034/ze/Kanban_CRUD-sample_(1)-1199345878
Documentation: https://ej2.syncfusion.com/angular/documentation/kanban/data-binding/#url-adaptor
- Package version that you have used
- If possible please share us with the issue sample or modify the above sample to replicate the issue
- Exact use case scenario and how the card data is updated in the component.
- The video illustration of the issue reproducing scenario.
Thank you Sharon,
I manage to work it out with you sample, but I have still some issues.
As a reminder, my need is to refresh a listview / a diagram / a kanban with updated remote data without reloading the page, not after CRUD actions but after filtering actions.
- ListView:
- it works fine.
- I don't find how to set/unset the e-listview-fieldsettings.groupby in the javascript section
- I use the actionComplete method of the list view like this
-
Kanban
- it works fine.
- Same question for the groupby property
- it works fine.
- Diagram
- It doesn't work. It seems more complicated with the nodes and the connectors part. Can you provide a example?
function actionComplete (args) {
if (args.result.length === 0) {
$("#noItemList").show();
}
}
When I load the updated data, I have a problem on args.result.length, and I don't know why. (It works when loading the initial data.)
Many thanks for your support,
Regards,
Laurent
Please find the details below.
|
function refershDiag() {
// make any change the service.
var diagram = document.getElementById("diagram").ej2_instances[0];
diagram.refresh();
}
|
Thanks for the reply, it helps.
There is a last point because we misundertsood each others: I don't find how to manage the listview groupby and the kanban swimlane in javascript. I know how to do it in the aspnet. I want to set and unset listview groupby and the kanban swimlane in a javascript function.
Best regards,
Laurent
|
function onButtonClick() {
$.ajax({
url: '/ListView/ReceiveData',
type: 'POST',
dataType: 'json',
success: function (result) {
var list = document.getElementById("userList").ej2_instances[0];
list.dataSource = result;
list.fields.groupBy = "RoleCategory";
}
})
} |
|
function onButtonClick() {
kanbanObj.swimlaneSettings.keyField = 'Assignee';
}
|
Sample: https://www.syncfusion.com/downloads/support/forum/166955/ze/LIA16B~1-426658904
Perfect!
Thanks for your reply.
Regards,
- 7 Replies
- 3 Participants
-
LA Laurent
- Jul 5, 2021 05:23 PM UTC
- Jul 13, 2021 06:00 AM UTC