We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

grid datasouce ajax update problem

Thread ID:





131457 Jul 11,2017 05:04 AM UTC Jul 14,2017 01:33 PM UTC JavaScript 3
Tags: ejGrid
Asked On July 11, 2017 05:04 AM UTC

When I'm updating datasource of the grid, it substitutes as total number of documents equal to the number of received value
for example: Count of documents = 70, controllers query takes 8 documents, and after changing datasource max docs count equals 8 and pagination shows 1 page instead of 9.

Controller returns:
return Json(new { result = data /*8 elemetnts which on the page*/, count = count /*total count = 70*/ });
contentType: 'application/json; charset=utf-8',
dataType: 'json',
url: '@Url.Action("GetDocs", "Documents")',
data: filterObj,
type: 'post',
success: function (res) {
var parsedData = ej.parseJSON(res);
$("#BoxesListGrid").ejGrid("dataSource", parsedData.result);
How to bind total count of docs?

Vignesh Natarajan [Syncfusion]
Replied On July 12, 2017 03:59 PM UTC

Hi John, 
Thanks for contacting Syncfusion support. We have analyzed your query and we are able to reproduce the issue at our end. 
We have prepared a sample based on the code you provided. 
While updating the dataSource,  you have considered only the .result value. So that grid has only that much records when updating. If you want total records to be displayed you can return all the records when updating. 
function complete(args) { 
         // var vinet = "VINET"; 
            url: '@Url.Action("GetDocs")', 
            type: "POST", 
            dataType: "json", 
            //contentType: 'application/json; charset=utf-8', 
            data: { value: 70, count: 8  }, 
            success: function (data) { 
                var parsedData = data; 
                $("#Grid").ejGrid("dataSource", parsedData.result); 
   Or else if you want to display current page records alone you can use URL adaptor of Data manager in which it will return count and total records simultaneously.  
$("#Grid").ejGrid("dataSource", ej.DataManager({url:"UrlDataSource", adaptor: new ej.UrlAdaptor() }); 
ServerSide code: 
public ActionResult UrlDataSource(DataManager dm)        {            IEnumerable DataSource = OrderRepository.GetAllRecords();            DataOperations ds = new DataOperations();            List<string> str = new List<string>();            var count = DataSource.Cast<EditableOrder>().Count();            DataSource = ds.PerformSkip(DataSource, dm.Skip);            DataSource = ds.PerformTake(DataSource, dm.Take);            return Json(new { result = DataSource, count = count, aggregate = aggregate });        }
In above code snippet Datasource represent current page records, where count represent the total record count   
Please refer our online sample for your reference 
Vignesh Natarajan 


Replied On July 14, 2017 03:15 AM UTC

if I use datamanager, how to send json object as a param to controller?

Saravanan Arunachalam [Syncfusion]
Replied On July 14, 2017 01:33 PM UTC

Hi John, 
We understood from your query, you need to send additional parameter to the controller and we have achieved this requirement by using query property of Grid control. In the query property, we have send additional parameter by using addParams method of ejQuery that can be refer from the below code example. 
$(function () { 
        var dataManager = ej.DataManager({ url: "/Home/DataSource", adaptor: new ej.UrlAdaptor() }); 
            dataSource: dataManager, 
            query: new ej.Query().addParams("value", 5 ).addParams("count",6), 
            . . . 
public ActionResult DataSource(Syncfusion.JavaScript.DataManager value, Test t) 
            . . . 
        public class Test 
            public string value { get; set; } 
            public int count { get; set; } 
And we have created a sample that can be downloaded from the below link. 
Saravanan A. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon