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.
Syncfusion Feedback

Check are there rusults from the server

Thread ID:

Created:

Updated:

Platform:

Replies:

132477 Sep 4,2017 05:58 PM UTC Sep 7,2017 04:05 AM UTC JavaScript 5
loading
Tags: ejGrid
noName
Asked On September 4, 2017 05:58 PM UTC

JS:
var dm = ej.DataManager({
    url: "/Home/get", crossDomain: true,
    updateUrl: '/Home/update',
    adaptor: new ej.UrlAdaptor()
});


$("#Grid").ejGrid({
    dataSource: dm,
    allowScrolling: true,
    allowVirtualScrolling: true,
    filterSettings: {
        filterType: "menu"
    },
    pageSettings: { enableQueryString: true, pageSize: 10 },
    columns: [
        { field: "data", headerText: "Data", isPrimarykey: true },
        { field: "value", headerText: "Value" },
    ]

});
I want to check if there are results from the server and if there are create/show grid.
How can I check that ?

Renjith Singh Rajendran [Syncfusion]
Replied On September 5, 2017 12:58 PM UTC

Hi Customer, 

We have analyzed your query. We have achieved your requirement by using DataManager “executeQuery” and the jQuery “done” method. The done function is called for each successful post. We have checked a condition for the data returned from server. If no data is returned, the Grid won’t be rendered. If the dataSource is not empty, Grid will be renedered. Please refer the sample below, 

<script type="text/javascript"> 
    $(function () { 
        var dataManager = ej.DataManager({ url: "UrlDataSource", adaptor: new ej.UrlAdaptor() }); 
        var query = ej.Query().take(3); 
        var execute = dataManager.executeQuery(query)  
                .done(function (e) { 
                    if (e.actual.result.length) {         
                        $("#Grid").ejGrid({ 
                            dataSource: e.actual.result, 
                            ... 
                        }); 
                    } 
                }); 
    }); 
</script> 

Please refer the documentation link below, 

We have also prepared a sample based on your requirement, which can be downloaded from the link below, 
Regards, 
Renjith Singh Rajendran. 


noName
Replied On September 5, 2017 10:21 PM UTC

Hi, thanks. It works, but in this way I am loosing infinity scroll. How can I set it back with your example ? Infinity scroll works if I set:

dataSource: dataManager

, but I think this is second request.


Renjith Singh Rajendran [Syncfusion]
Replied On September 6, 2017 01:04 PM UTC

Hi Customer, 

Query 1: I am loosing infinity scroll 
 
In our last update we have not included the allowVirtualScrollingproperty of Grid. This is the reason for infinity scroll not enabled. Please refer the sample below, 

<script type="text/javascript"> 
    $(function () { 
         ... 
         $("#Grid").ejGrid({ 
            ... 
           allowScrolling: true, 
            scrollSettings: { height: 200, allowVirtualScrolling: true }, 
            ... 
         }); 
         ... 
   }); 
</script> 

Please download the modified sample from the link below, 

And also in the code example provided by you, the allowVirtualScrolling was not provided in proper format. The allowVirtualScrolling must be inside the scrollSettings property of Grid. 

Query 2: Infinity scroll works if I set: dataSource: dataManager 
 
In the provided sample, we have bound the JSON Data to the Grid. If you need to load the data on demand while scrolling you can bind dataManager to the dataSource. Please refer the code below, 

<script type="text/javascript"> 
    $(function () { 
         var dataManager = ej.DataManager({ url: "Home/UrlDataSource", adaptor: new ej.UrlAdaptor() }); 
         ... 
         $("#Grid").ejGrid({ 
            dataSource: dataManager,             
            ... 
         }); 
         ... 
   }); 
</script> 

Regards, 
Renjith Singh Rajendran. 


noName
Replied On September 6, 2017 02:51 PM UTC

 By infinity scroll I mean load the data on demand while scrolling. Now I understand that I need to use 2 requests.

Ok, thx. Everything works.


Mani Sankar Durai [Syncfusion]
Replied On September 7, 2017 04:05 AM UTC

Hi Customer, 

We are happy to hear that your problem has been solved. 

Please let us know if you need further assistance. 

Regards, 
Manisankar Durai. 


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.

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

;