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: load data only on demand

Thread ID:

Created:

Updated:

Platform:

Replies:

121048 Nov 5,2015 05:23 PM UTC Nov 6,2015 09:25 AM UTC ASP.NET Web Forms 1
loading
Tags: Grid
Jorge Pampin
Asked On November 5, 2015 05:23 PM UTC

Hello,

There is a way to configure the Grid Control to load the data only with the code gridObj1.refreshContent(); and WebMethodAdaptor? I don't want the grid to load the data at begining.

Thanks!

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On November 6, 2015 09:25 AM UTC

Hi Jorge,

We can bind the dataSource to the Grid later using setModel, after binding the empty dataSource to the Grid at initial render. Please refer to the below code example.

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">

    <ej:button id="ButtonNormal" type="Button" runat="server" clientsideonclick="btnClick" text="Button"></ej:button>

    <ej:grid id="EmployeesGrid" runat="server" width="1500px" allowpaging="true">

                <!--DataSource is Empty at intial Render-->

                <Columns>

                        <ej:Column Field="OrderID" IsPrimaryKey="true" HeaderText="Order ID" Width="80" />

                        . . .  .

                </Columns>      

            </ej:grid>

    <script>

        function btnClick(e) {

            $("#MainContent_EmployeesGrid").ejGrid({ dataSource: ej.DataManager({ url: "Default.aspx/Data", adaptor: new ej.WebMethodAdaptor() }) })

        }

    </script>
</asp:Content>

[Code Behind]

[WebMethod]

        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]

        public static object Data(Syncfusion.JavaScript.DataManager value)

        {

            IEnumerable Data = OrderRepository.GetAllRecords();

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

            return new { result = Data, count = count };


        }


For your Convenience, we have prepared a sample that can be downloaded from the below location

Sample:  http://www.syncfusion.com/downloads/support/forum/121048/ze/EjGrid-312448390

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.

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

;