Ticket T267537
Visible to All Users

GridView - Update data when page change

created 10 years ago (modified 10 years ago)

Hi

This is ny gridView, my data source is a data table with a lot of image, these image need create in run time, but create too much image need a lot of time, so i hope when i do page change, i just create image on next page index, but when i change page index to 2 but i always get page index 1 in BeginCallback function, i need get next index not pre indexx, is any function can get it?

C#
@model HMIWebServer.Models.GridViewData @Html.DevExpress().GridView(    settings =>   {        settings.Name = "myGridView";        settings.CallbackRouteValues = new { Controller = "HMIWeb", Action = "RefreshGridViewPartial" };        settings.ClientSideEvents.ColumnSorting = "GetSortedColumnIndex";        settings.ClientSideEvents.DetailRowCollapsing = "GetDetailRow";        settings.CommandColumn.ShowSelectCheckbox = true;        settings.CommandColumn.Width = 40;        settings.Width = Unit.Percentage(100);        settings.Height = 1000;        settings.Settings.HorizontalScrollBarMode = ScrollBarMode.Auto;        settings.Settings.VerticalScrollBarMode = ScrollBarMode.Auto;        settings.Settings.VerticalScrollableHeight = 500;        settings.SettingsBehavior.AllowFocusedRow = true;        settings.SettingsPager.PageSize = 10;        settings.SettingsPager.NumericButtonCount = 4;        settings.KeyFieldName = "Index";        settings.SettingsBehavior.AllowSort = false;        if (Model.GridViewTable != null && Model.GridViewTable.Columns.Count > 1)        {            settings.SettingsPopup.HeaderFilter.Height = 100;            int ColumnIndex = 0;            foreach (System.Data.DataColumn column in Model.GridViewTable.Columns)            {                if (column.DataType == System.Type.GetType("System.Byte[]"))                {                    settings.Columns.Add(column.ColumnName, MVCxGridViewColumnType.BinaryImage);                    settings.Columns[ColumnIndex].Width = 100;                }                else                {                    settings.Columns.Add(column.ColumnName);                    settings.Columns[ColumnIndex].Width = 80;                }                ColumnIndex++;            }        }        settings.CommandColumn.ShowSelectCheckbox = true;        settings.CommandColumn.ShowClearFilterButton = true;        settings.CommandColumn.SelectAllCheckboxMode = GridViewSelectAllCheckBoxMode.AllPages;        settings.CommandColumn.Visible = true;        settings.ClientSideEvents.BeginCallback = "OnGridBeginCallback";        settings.ClientSideEvents.EndCallback = "OnGridEndCallback";        settings.ClientSideEvents.FocusedRowChanged = "OnGridFocusedRowChanged";        settings.ClientSideEvents.SelectionChanged = "OnGridViewSelectionChanged";        settings.PreRender = (sender, e) =>        {            ASPxGridView gridView = (ASPxGridView)sender;            for (int i = 0; i < gridView.VisibleRowCount; i++)            {                gridView.Selection.SetSelection(i, true);            }        };    }).Bind(Model.GridViewTable).GetHtml()

Answers approved by DevExpress Support

created 10 years ago

Hi,

You can implement Custom Data Binding for this purpose. For instance, review the How to: Implement Custom Data Binding with Paging and Sorting help section and E4394 - How to implement a simple custom binding scenario for GridView code example. Take special note of the CustomBindingHandlers.GetData method. Data items that correspond only to the current page are returned by this method.

Thanks,
Alessandro.

    Comments (2)

      Hi Alessandro
      I have  test custom data binding, but my data column is not fixed, so i usually create a new datatable or a list to assignee data in GetData function, but it will show error lost primary key

      Artem (DevExpress Support) 10 years ago

        Hi Chien,

        This information isn't sufficient to give you a precise solution. Would you please elaborate on your scenario and send us the following data:

        1. A screencast or some screenshots illustrating your scenario (for example, you can use the Jing Tool to capture them).
        2. Code snippets illustrating your model logic or a runnable test sample, so we can research your scenario in action.

        Your time and cooperation are greatly appreciated.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.