Grid doesn't show data but data property of datamanager is set

Hello,

I'm struggling to figure out why the data for the grid isn't showing up. The Grid says: No records to display.

The generated JavaScript but shows that the data was "found" as I unterstand it. I think I have done everything correct and I don't see what's the problem.

TagHelper Code:

    <ejs-grid allowPaging="true"

              id="audienceGrid"

              actionFailure="failure"

              actionBegin="begin"

              actionComplete="completed"

              toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel","Search" })">

        <e-data-manager data="@Model"

                        insertUrl="@Url.Action("Add", "Audience")"

                        removeUrl="@Url.Action("Delete", "Audience")"

                        updateUrl="@Url.Action("Edit", "Audience")">

        </e-data-manager>

        <e-grid-pagesettings pageSize="10"></e-grid-pagesettings>

        <e-grid-editsettings allowAdding="true" allowDeleting="true" allowEditing="true" mode="Dialog"></e-grid-editsettings>

        <e-grid-columns>

            <e-grid-column isIdentity="true" field="@nameof(TargetAudianceDto.Id)" headerText="Id"></e-grid-column>

            <e-grid-column field="@nameof(TargetAudianceDto.Audience)" headerText="Audience"></e-grid-column>

        </e-grid-columns>

    </ejs-grid>


Generated JavaScript from TagHelper:

new ejs.grids.Grid({

  "allowPaging": true,

  "columns": [

    {

      "field": "Id",

      "headerText": "Id",

      "isIdentity": true

    },

    {

      "field": "Audience",

      "headerText": "Audience"

    }

  ],

  "dataSource": new ejs.data.DataManager({

  "insertUrl": "/management/audience/add",

  "removeUrl": "/management/audience/delete",

  "updateUrl": "/audience/edit",

  "data": [

    {

      "Id": 1,

      "Audience": "Family"

    },

    {

      "Id": 2,

      "Audience": "Kids"

    },

    {

      "Id": 3,

      "Audience": "Men"

    },

    {

      "Id": 4,

      "Audience": "Women"

    },

    {

      "Id": 5,

      "Audience": "Adults"

    }

  ]

}),

  "editSettings": {

    "allowAdding": true,

    "allowDeleting": true,

    "allowEditing": true,

    "mode": "Dialog"

  },

  "ej2StatePersistenceVersion": "default version",

  "frozenColumns": 0.0,

  "frozenRows": 0.0,

  "pageSettings": {

    "currentPage": 1.0,

    "pageCount": 8.0,

    "pageSize": 10.0

  },

  "selectedRowIndex": -1.0,

  "toolbar": [

    "Add",

    "Edit",

    "Delete",

    "Update",

    "Cancel",

    "Search"

  ],

  "actionBegin": begin,

  "actionComplete": completed,

  "actionFailure": failure

}).appendTo("#audienceGrid");


9 Replies 1 reply marked as answer

BS Balaji Sekar Syncfusion Team December 27, 2021 12:30 PM UTC

Hi Pascal, 

Greetings from the Syncfusion support. 

Based on your query, we found that you have use “data” instead of  json” in “ejs-data-manager” and we suggest you to use adaptor property in that tag. Please use the RemoteSaveAdaptor in your sample to overcome the reported problem. 

Please refer the below modified code example for more information. 

   <e-data-manager json="@Model" 
                        insertUrl="@Url.Action("Add", "Audience")" 
                     adaptor=”RemoteSaveAdaptor”> 
        </e-data-manager> 


Please get back to you, if you need further assistance. 

Regards, 
Balaji Sekar. 



PA Pascal replied to Balaji Sekar December 27, 2021 12:37 PM UTC

Thank you very, very much, it worked. Wish you a good day and hopefully a happy new year. Thanks



PA Pascal December 27, 2021 10:20 PM UTC

Hello Balaji,

sorry to bother you again, but now I have an weird problem that the grid doesn't send the data if I use for example the insert method... It's null and if I look into the post header via developer tools I don't find data send, but the grid knows the correct url~


Could you please help me out there too? The code is the same with your changes using json and the adapter now.

My add method looks like this g is always null currently:

        public IActionResult Add([FromBody] SyncfusionOperationModel<TargetAudianceDto> g)

        {

            _taRepo.Add(g.Value);

            return Json(g.Value);

        }


and the crud model I use is from your sample projects (just renamed a little bit^^):

    public class SyncfusionOperationModel<T> where T : class

    {

        [JsonProperty("action")]

        public string Action { get; set; }

        [JsonProperty("table")]

        public string Table { get; set; }

        [JsonProperty("keyColumn")]

        public string KeyColumn { get; set; }

        [JsonProperty("key")]

        public object Key { get; set; }

        [JsonProperty("value")]

        public T Value { get; set; }

        [JsonProperty("added")]

        public IList<T> Added { get; set; }

        [JsonProperty("changed")]

        public IList<T> Changed { get; set; }

        [JsonProperty("deleted")]

        public IList<T> Deleted { get; set; }

        [JsonProperty("params")]

        public IDictionary<string, object> @params { get; set; }

    }



BS Balaji Sekar Syncfusion Team December 28, 2021 04:41 PM UTC

Hi Pascal, 

We are happy to resolved the problem. 

Query: Grid doesn't send the data if I use for example the insert method 
 
Currently, we are validating the above query and we will update further details on December 29, 2021 

Until then we appreciate your valuable patience. 

Regards, 
Balaji Sekar. 



BS Balaji Sekar Syncfusion Team December 29, 2021 01:33 PM UTC

Hi Pascal, 

Thanks for your valuable patience. 

Based on your query, we suggest you to use value property instead of “g” in insert method of server and we can get the required parameters with values when inserted row on Grid. 

Please refer the below code example for more information. 

[HomeController.cs] 
        //insert the record 
        public ActionResult Insert([FromBody]CRUDModel<OrdersDetails> value) // get the parameters in value property so use property value instead of “g”  
        { 
            OrdersDetails.GetAllRecords().Insert(0, value.value);  
            return Json(value); 
        } 

Please get back to us, if you need further assistance. 

Regards, 
Balaji Sekar. 



PA Pascal December 29, 2021 01:47 PM UTC

 Hello Balaji,

sadly that didin't help. The main cause is somehow that there's no data in the sent header.

I've copied the post request that the grid sends to the server, you'll see that there's no data from:


:authority: localhost:44335

:method: POST

:path: /management/audience/add

:scheme: https

accept: */*

accept-encoding: gzip, deflate, br

accept-language: ja,de-DE;q=0.9,de;q=0.8,en-US;q=0.7,en;q=0.6

cache-control: no-cache

content-length: 57

content-type: application/json; charset=UTF-8

cookie: .AspNetCore.Antiforgery

dnt: 1

origin: https://localhost:44335

pragma: no-cache

referer: https://localhost:44335/management/audiance

sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="98", "Microsoft Edge";v="98"

sec-ch-ua-mobile: ?0

sec-ch-ua-platform: "Windows"

sec-fetch-dest: empty

sec-fetch-mode: cors

sec-fetch-site: same-origin

user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4741.0 Safari/537.36 Edg/98.0.1100.3



RS Rajapandiyan Settu Syncfusion Team December 30, 2021 12:42 PM UTC

Hi Pascal,  

Thanks for your patience. 

We are tried to reproduce the reported behavior with the provided code example, but it was unsuccessful at our end. The CRUD actions are working fine with the RemoteSaveAdaptor. Find the below sample for your reference. 


By analyzing your issue, we suspect that you may not handle the nullable type on integer and DateTime fields in your Class Model. This may also cause the reported behavior. 

So, we suggest you to give nullable type for integer and dateTime fields in the Model definition as demonstrated in the below code snippet, 


public class BigData 
        { 
            --- 
            public int? OrderID { get; set; } 
            public string Id { get; set; } 
            public int? N1 { get; set; } 
            ---- 
            public double? Freight { get; set; } 
            public DateTime? OrderDate { get; set; } 
            --- 
        } 


Find the below documentation for your reference. 


Still, if you face the same issue, kindly share the below details to replicate at our end. 

  1. Share the issue reproducible sample or try to make the issue in the given sample.
  2. Share the screenshot of Network Tab details like below.
 

Regards,  
Rajapandiyan S 


Marked as answer

PA Pascal replied to Rajapandiyan Settu December 30, 2021 01:01 PM UTC

Okay, now after I marked the string Property as Nullable (I use .NET 6 were Nullable Context is enabled by default ) it worked... Thank you haven't thought that this could even be a problem, but now I know of I'll pay attention to that. Thank you very much and wish you and your team a happy new year.



SK Sujith Kumar Rajkumar Syncfusion Team December 31, 2021 07:10 AM UTC

Hi Pascal, 

You’re welcome. We are glad to hear that your query has been resolved. 

And we wish you a very happy new year. 

Regards, 
Sujith R 


Loader.
Up arrow icon