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. Image for the cookie policy date
close icon

Grid and Binding with DataManager


        public IActionResult GetIndexData([FromBody]DataManager dm)
        {
            var list = _context.Pilots.Skip(dm.Skip).Take(dm.Take).Include(p => p.Union).
                                Include(p => p.Masterlist).Include(p => p.Instructor).ToList();       //Second Trip kills this query because DM is NULLLLLLL

            return Json(new { result = list, count = list.Count });
        }


<ej-grid id="pilotgrid" allow-searching="true" allow-filtering="true" 
                     query="new ej.Query().select(['PilotId', 'FirstName', 'LastName', 'CompanyId', 'PreMergerId', 'Legacy', 'DOB', 'DOH', 'SeparationDate', 'LOAExp', 'StatusCode', 'Notes']).take(50)"
                     allow-grouping="true" show-stacked-header="true" allow-paging="true">
                <e-datamanager id="DataManager" url="/Pilots/GetIndexData" adaptor="@AdaptorType.UrlAdaptor" />


For what ever reason, it must be me since I still have issue most of your tools associated with the failure that is DataManager,  the query specified in the Grid NEVER gets executed beyond  'take(12)' (default)???.  Can you explain this and the bold comment happens.... 

1 Reply

SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team June 16, 2017 09:33 AM UTC

Hi Morgan,  
 
Thanks for contacting Syncfusion Support.  
 
We could see you would like to populate the Grid in on-demand. In the provided code example, you have returned the count incorrectly, which is the cause of the problem. The count must be total records that found in the datasource. Based on the count, paging action will be done. Refer to the following code example. 
 
<ej-grid id="FlatGrid"  allow-paging="true" 
           query="new ej.Query().select(['ID','CustomerID','EmployeeID'])" 
         > 
    <e-datamanager url="/Home/GetIndexData" adaptor="UrlAdaptor" /> 
        . . .  
             . . . 
</ej-grid> 
 
        public IActionResult GetIndexData([FromBody]DataManager dm) 
        { 
            IEnumerable datasource = order; 
            DataOperations operation = new DataOperations(); 
            int count = datasource.AsQueryable().Count(); 
            if (dm.Select != null)//select required columns 
                datasource = operation.PerformSelect(datasource, dm.Select); 
            if (dm.Skip >= 0)//for paging 
                datasource = operation.PerformSkip(datasource, dm.Skip); 
            if (dm.Take > 0)//for paging 
                datasource = operation.PerformTake(datasource, dm.Take); 
 
            return Json(new { result = datasource, count = count }); 
        } 
 
We have already discussed about the server-end data operations in the following KB.  
 
 
Request 
Response 
 - Initial Load of the Grid 
 
 
 
 
 
-          Paging action 
 
 
Result must hold 12 records as per the request but the count is total records. 
 
We have prepared a sample that can be downloaded from the following location.  
 
 
If you would like to change the default value of the take (12), you can change the default page-size of the Grid e-page-settings which will alter the take value. Refer to the following code example and Help Documents.  
 
<ej-grid id="FlatGrid"  allow-paging="true" 
           query="new ej.Query().select(['ID','CustomerID','EmployeeID'])" 
         > 
    <e-datamanager url="/Home/GetIndexData" adaptor="UrlAdaptor" /> 
    <e-page-settings page-size ="10"/> 
         . .  
              . .  
</ej-grid> 
 
 
Regards,  
Seeni Sakthi Kumar S. 


Loader.
Live Chat Icon For mobile
Up arrow icon