couple of issues on update

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.






1 Reply

RR Rajapandi Ravi Syncfusion Team March 31, 2020 10:54 AM UTC

Hi Patrice, 

Greetings from syncfusion support 

Based on your query we have prepared a sample with your application scenario and tried to reproduce the issue but it works fine from our end. Please refer the below screenshot and sample for more information. 

Screenshot: 

In this below image, We have update the value “CHANG”. 

 

And the updated value received from server end. Then we override the value to “SAVED”   
 

And return the updated value from server by using Value.Value. From checking your query we suspect you are not returning the Json value correctly. So, we suggest you not return the entire value instead of that return the updated value alone by using Value.Value 

 

The override value “SAVED” was updated in the Grid without calling refresh method. 
 



If you still face the issue, Please share the below details that will be helpful for us to provide better solution. 

  1. Please share the issue scenario in video format
  2. Please reproduce the issue in our above attached sample

Query#: The columns that are shown as enums not correctly after updating 

Based on you query we have prepared a sample with Enum values it works fine from our end. Please refer the below code example, video demo and sample for more information. 
 
public class OrdersDetails 
    { 
        public static List<OrdersDetails> order = new List<OrdersDetails>(); 
        . . . . . 
        public DateTime ShippedDate { get; set; } 
        public string ShipAddress { get; set; } 
        [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] 
        [DisplayFormat(NullDisplayText = "No grade")] 
        public Grade? grade { get; set; } 
    } 
 
    public enum Grade 
    { 
        A, B, C, D, F 
    } 



Regards, 
Rajapandi R

Loader.
Up arrow icon