Hi,
I'm having a couple of issues on update for a grid (.net core) implementing a custom urlAdaptor.
Here's the code:
<ejs-grid id="Grid" created="created" actionBegin="actionBegin" actionComplete="actionComplete" actionFailure="actionFailure"
allow-resize-to-fit="true" allowPaging="true" allowSorting="true"
toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })">
<e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true" mode="Dialog" template='#dialogtemplate'></e-grid-editSettings>
<e-grid-pagesettings pageSize="10"></e-grid-pagesettings>
<e-data-manager url="/Admin/UrlDatasource" adaptor="UrlAdaptor" insertUrl="/Admin/Create" updateUrl="/Admin/Edit" removeUrl="/Admin/Delete"></e-data-manager>
<e-grid-columns>
<e-grid-column field="Id" headerText="Id" textAlign="Right" isPrimaryKey="true" visible="false"></e-grid-column>
<e-grid-column field="Name" headerText="Name" textAlign="Left" type="string" width="120"></e-grid-column>
<e-grid-column field="Ressource" headerText="Url" textAlign="Left" clipMode="EllipsisWithTooltip" type="string" width="120"></e-grid-column>
<e-grid-column field="RunEvery" headerText="Refresh" textAlign="Left" type="string" width="100"></e-grid-column>
</e-grid-columns>
</ejs-grid>
1. Data updates on the server side is not refresh on the grid.
The column RunEvery is updated on the server for when the user selects a number inferior to a minimum based on the user membership. That needs to happen server side for security reason. Here's the code in the controller:
...
if((MembershipType)user.MembershipType == MembershipType.Basic) {
condition.RunEvery = value.RunEvery > 300 ? value.RunEvery : 300;
} else if((MembershipType)user.MembershipType == MembershipType.Pro) {
condition.RunEvery = value.RunEvery > 60 ? value.RunEvery : 60;
}
_context.Update(condition);
await _context.SaveChangesAsync();
So it works that way:
- The user enters a value of 30 for RunEvery in the update dialog, saves, which posts, the controller receives the data in the model, compare the value to the minimum, modify the value RunEvery to 300, saves the context, and returns the object to the client side as json, with the value: RunEvery=300, but the client side grid keeps showing 30 as it was before updating. Now, if I refresh the page where the grid is, using F5, the value RunEvery=300 shows up, consistent with the data in the DB.
What am I missing here, do I need to "grid.refresh()" after receiving the update response from the server?
2. The columns that are shown as enums correctly on the first loading (call to UrlDataSource), turn back to int after updating. I Checked the json data, in both cases, the data that is sent to the grid has enum labels rather than the int.
This is the grid:
<e-grid-column field="ConditionType" headerText="Cond. Type" type="string" textAlign="Right" width="120"></e-grid-column>
<e-grid-column field="ComparisonType" headerText="Comparison" type="string" textAlign="Right" width="120"></e-grid-column>
Here you can see the first has not been updated and shows as enum labels while the second record here is the same after updating.
Thanks for your help, I've searched online, both your documentation and forums, but couldn't find any answer that applied to my case.