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.

Set Skip and Take for infinity scroll

Thread ID:

Created:

Updated:

Platform:

Replies:

132384 Aug 29,2017 03:01 PM Sep 5,2017 01:34 AM JavaScript 10
loading
Tags: ejGrid
noName
Asked On August 29, 2017 03:01 PM

I have this JS which creates a grid:

var dm = ej.DataManager({
    url: "/users/get/", crossDomain: true ,
    adaptor: new ej.UrlAdaptor() 
});


    $("#Grid").ejGrid({
        dataSource: dm,
        allowScrolling: true,
        allowVirtualScrolling: true,
        filterSettings: {
            filterType: "menu"
        },
        allowFiltering: true,
        scrollSettings: { width: "auto", height: 300, allowVirtualScrolling: true, virtualScrollMode: ej.Grid.VirtualScrollMode.Continuous },
        pageSettings: { pageSize: 10 },
        pageSettings: { enableQueryString: true },
        columns: [
            { field: "id", headerText: "ID", isPrimarykey: true},
            { field: "email", headerText: "Email" },
        ]

});
And this server-side action:
    public IActionResult All(DataManager dm)
        {
            var data = Users.All();
            DataOperations operation = new DataOperations();

            int count = data.AsQueryable().Count();
            if (dm.Skip != 0) 
            {
                 data = operation.PerformSkip(data, dm.Skip);
            }
            if (dm.Take != 0) 
            {
                data =  operation.PerformTake(data, dm.Take);
            }


            return Json(new { result = data, count = count });
        }
The Items are 30 and infinity scroll loads elements when it is at the bottom, but it loads every time same 30 items, because Take and Skip are 0 every time.
I want to set Skip and Take to get (for the example) 10 items and with infinity scroll loading new 10 items and new 10 to the end of the elements.
Is there SynqFusion way to that or I need to create it manual ?

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On August 30, 2017 01:17 AM

Hi Customer,  
 
Thanks for contacting Syncfusion Support.  
 
We are unable to reproduce any problem at our end. We have prepared a sample that can be downloaded from the following location.  
 
 
We could see the Grid sends the skip/take and brings next page records as shown in the following screenshot.  
 
 
 
Please share the following details to analyze the problem at our end.  
 
  1. Screenshot with the replication procedure or video demo of the issue
  2. Version of the Essential Studio
  3. If possible, modify the attached sample and reproduce the issue
 
 
Regards,  
Seeni Sakthi Kumar S. 
 


noName
Replied On August 30, 2017 11:02 AM

In my app it set Skip and Take in JS and send them to the server, too: 

  • {requiresCounts: true, skip: 0, take: 10}
    1. requiresCounts:true
    2. skip:0
    3. take:10

    , but on the server dm.Take and dm.Skip are 0 in all cases and returns no results if in the server dm.Take is not set like this dm.Take = 10, for the example. JS code is same like in your sample:

    Server side code is:

    IEnumerable data = Users.Get(dm.Skip, dm.Take);  //dm.Skip and dm.Take are 0

                DataOperations operation = new DataOperations();

                int count = data.AsQueryable().Count();

                return Json(new { result = data, count = count });

    In your sample it works and in the action dm.Take and Skip aren't 0 in my application there are 0.










    Seeni Sakthi Kumar Seeni Raj [Syncfusion]
    Replied On August 31, 2017 06:48 AM

    Hi Customer,  
     
    We could see you are taking the count after applying the Skip/Take arguments to the Data which will bring wrong count to the client end. So, we request to take the count before applying the Skip/Take to the DataSource.  
     
           public ActionResult DataSource(Syncfusion.JavaScript.DataManager dm) 
     
            { 
     
               int count = Users.Count();//collect the record count first 
     
                IEnumerable data = Users.Get(dm.Skip, dm.Take);  //apply skip/take later 
     
                DataOperations operation = new DataOperations(); 
     
                return Json(new { result = data, count = count }); 
            } 
     
    If you are still facing any problem, please share a video demo of the issue along with details requested in our previous update.  
     
    Regards,  
    Seeni Sakthi Kumar S. 


    noName
    Replied On August 31, 2017 11:07 AM

    I don't see option to upload images or any other media, that's why I attach screens it to the comment.

    With count before other code is same. You can check screens.


    Attachment: MVC_7c63d6ec.rar

    Venkatesh Ayothi Raman [Syncfusion]
    Replied On September 1, 2017 06:08 AM

    Hi Customer, 

    Thanks for the update. 

    We went through your screenshot that you have shared for us and found that you are showing two different controllers page one controller page has skip and take values and another has null values. We suspect that you are doesn’t enabling the page settings or doesn’t enabling the Virtual scrolling.  In this scenario, only both skip and take values are null. So, could you please check whether you are defining the pageSettings/Virtual scrolling.  
    Please refer to the following code example, 

    Please share the following details to analyze the problem at our end.   
      
    1. Scenario for replication procedure.
    2. Version of the Essential Studio
    3. A sample If possible or modify the attached sample and reproduce the issue

    Regards, 
    Venkatesh Ayothiraman. 


    noName
    Replied On September 1, 2017 09:35 AM

    My JS code is copy/paste from your sample:

    dataSource: dm,

                allowScrolling: true,

                scrollSettings: { width: "auto", height: 300, allowVirtualScrolling: true, virtualScrollMode: ej.Grid.VirtualScrollMode.Continuous },

                pageSettings: { pageSize: 10, enableQueryString: true },

    .......


    1 of the images where dm.Take is not null is from your sample when I debug.

    The image where Take and Skip are 0 is from my app when I debug.

    I am using Visual Studio Community 2017.

    The app is .NET Core.

    I can provide files from the app, but not here, where is public.  

    I really need to fix this.


    noName
    Replied On September 1, 2017 11:40 AM

    This sample describe the problem. It is .NET Core Syncfusion application created with Visual Studio projects->Syncfusion ASP.NET Core Web Application.

    The problem is same. If you run the app you can see that there is request with take: 10, but on the server is 0.

    Even more, if I send custom query like this:

    .....executeQuery(new ej.Query().addParams("id", "value").requiresCount().skip(1).take(3)); 

    I see in the console this:

    1. {requiresCounts: true, skip: 1, take: 3, id: "value"}
      1. id:"value"
      2. requiresCounts:true
      3. skip:1
      4. take:3

    , but on the server everything is null/0.








    Attachment: SyncfusionASPNETCoreWebApp_1155f04f.rar

    Seeni Sakthi Kumar Seeni Raj [Syncfusion]
    Replied On September 4, 2017 04:38 AM

    Hi Customer,  
     
    Thanks for contacting Syncfusion Support.  
     
    We suspect that you are missing FromBody attribute in the Url Action Handler. If the attribute is not present, default values will be set the parameter instead of the receiving values from the client-end. So, we suggest to mention this in the Handler function as shown in the following code example.  
     
            public ActionResult DataSource([FromBody]DataManager dm) 
            { 
                IEnumerable DataSource = order; 
                DataOperations ds = new DataOperations(); 
                int count = DataSource.Cast<Orders>().ToList().Count();//count 
                if (dm.Skip >= 0) 
                    DataSource = ds.PerformSkip(DataSource, dm.Skip); 
                if (dm.Take > 0) 
                    DataSource = ds.PerformTake(DataSource, dm.Take); 
                return Json(new { result = DataSource, count=count }); 
            } 
     
    If you are still facing any problem, please share the following details to analyze the problem at our end.  
     
    1. Complete code example of the Grid and the code behind
    2. Screenshot of the issue or video demo of the issue
     
    Regards,  
    Seeni Sakthi Kumar S. 


    noName
    Replied On September 4, 2017 09:59 AM

    Thanks, It works.

     I need to use adaptor: new ej.UrlAdaptor(), otherwise with another adaptor I am getting 415 (Unsupported Media Type), but now it works with UrlAdaptor()


    Seeni Sakthi Kumar Seeni Raj [Syncfusion]
    Replied On September 5, 2017 01:34 AM

    Hi Customer,  
     
    We are happy to hear that your requirement has been achieved. Since Controller actions were handled by the UrlAdaptor alone by DataManager, we must give the adaptor as UrlAdaptor. If the UrlAdaptor is not mentioned for the controller actions, DataManager will consider them as a OData operations which results in the Unsupported Type error. So, we request to mention in the adaptor.  
     
    Regards,  
    Seeni Sakthi Kumar S. 


    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.

    ;