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.
Unfortunately, activation email could not send to your email. Please try again.

Data Loading Finish,but don't Show

Thread ID:

Created:

Updated:

Platform:

Replies:

123798 Apr 22,2016 03:46 AM Apr 25,2016 08:25 AM JavaScript 1
loading
Tags: ejGrid
guoxuefeng
Asked On April 22, 2016 03:46 AM

JS Code:
<script type="text/javascript">
        $(function () {
            $("#Grid").ejGrid({
                locale: "zh-CN",
                dataSource: ej.DataManager({
                    url: "/Roles/DataSource",              
                    insertUrl: "/Roles/Insert",                  
                    adaptor: 'UrlAdaptor'
                }),
                allowPaging: true,
                editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true },
                toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Add, ej.Grid.ToolBarItems.Edit, ej.Grid.ToolBarItems.Delete, ej.Grid.ToolBarItems.Update, ej.Grid.ToolBarItems.Cancel] },
                columns: [
                { field: "Id", isPrimaryKey: true, headerText: '编号', allowEditing: false, textAlign: ej.TextAlign.Left },
                { field: "Name", headerText: "名称", editType: ej.Grid.EditingType.String, validationRules: { required: true, minlength: 1, maxlength:5 } },
                ]
            });
        });
    </script>
MVC 5 Code:
       public ActionResult DataSource(DataManager data)
        {
            var lst= Project_Web.Models.AspNetRolesService.Instance.GetAllModel(); // Get All Data
            return Json(new { result=lst,count=lst.Count },JsonRequestBehavior.AllowGet);
        }

        public ActionResult Insert(JObject value)
        {
            ParamInsert pi = new ParamInsert();
            pi.Insert(Project_Web.Models.AspNetRoles.TableName);
            pi.Column(Project_Web.Models.AspNetRoles.Column_Id, AspNetRolesService.Instance.GetNewCode()); //Get Max Code
            pi.Column(Project_Web.Models.AspNetRoles.Column_Name, DateTime.Now.ToString()); //Test
            AspNetRolesService.Instance.Insert(pi);  //Data Into Database
            var data = Project_Web.Models.AspNetRolesService.Instance.GetAllModel();
            return Json(data, JsonRequestBehavior.AllowGet);
        }

First request Finish,Data show Right;
Add Data and Submitted,Data insert into  Database Success;Data Return to client Success,
Problem:
  1. why new Data not Show in Grid?Using Chrome developer tools  find Data is Exist,Invoke Insert Method after.
  2. why client request URL "/Roles/DataSource"  again  when Insert Method return all data to client.  
  3.Can  return EmptyResult with in  Insert Method? (in MVC)


Gowthami V [Syncfusion]
Replied On April 25, 2016 08:25 AM

Hi guoxuefeng, 

Thanks for using Syncfusion products. 

Query 1: why new Data not Show in Grid? Using Chrome developer tools  find Data is Exist, Invoke Insert Method after. 
 
We have analyzed your issue and we are  unable to reproduce the issue.  
 
We have created a sample and the same can be downloaded from the following link, 
 
 
From your code example we found that you have used UrlAdapor. While using this adaptor It will work as OnDemand paging and return only current page data.  
 
But in your code example you have not handled paging operation in server side and returned all the data. We suspect that it may be the cause of the issue. So instead of returning all the data for every post,  return only the current page data using paging details passed in DataManager type parameter. 
 
Refer to the below code example, 
 
@(Html.EJ().Grid<OrderTable>("Grid") 
        .Datasource(ds => ds.URL("GetEmployeeData") 
                            .InsertURL("PerformInsert") 
                           
                            .Adaptor(AdaptorType.UrlAdaptor) 
                            ) 
            .AllowPaging() 
             
. . . . 
. . . . 
  ) 
 
public ActionResult GetEmployeeData(DataManager dm) 
        { 
 
            IEnumerable data = (from o in new NORTHWNDEntities1().Tables 
                                //Binding selected data instead of all data 
                                select new EmployeeTable 
                                { 
                                    EmployeeID = o.EmployeeID, 
                                    FirstName = o.FirstName, 
                                    LastName = o.LastName, 
                                    Title = o.Title 
                                }).OrderBy(o=> o.EmployeeID); 
 
            int count = data.AsQueryable().Count(); 
            DataOperations operation = new DataOperations(); 
            
            //Performing paging operations 
            data = operation.PerformSkip(data, dm.Skip); 
            data = operation.PerformTake(data, dm.Take); 
            
            return Json(new { result = data, count = count }, JsonRequestBehavior.AllowGet); 
 
        } 
 
 
Refer to the below link for more clarification about adaptors, 


Query 2: why client request URL "/Roles/DataSource"  again  when Insert Method return all data to client. 

When using “UrlAdaptor” , it will work with OnDemand paging concept like it will return only current page data. 
 
If we have performed Filtering, Sorting and Searching actions before performing CRUD operation then we need to fetch the current page data based on filter, sort actions since the data source collection is modified. 
 
So that only we have called the “DataSource” method after performing CRUD operation. 

Query 3: Can  return EmptyResult with in  Insert Method? (in MVC) 

Yes. We can return the EmptyResult with Insert method. 

Regards, 

Gowthami V. 


CONFIRMATION

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.

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.

;