jeudi 3 novembre 2016

Page Index is always 0 in devexpress gridview

Page Index is showing always zero.

I have implemented the Grid like the below Url: http://ift.tt/2egNxTW

and in the above url User's issue is resolved by using the below line of code
ModelBinders.Binders.DefaultBinder = new DevExpress.Web.Mvc.DevExpressEditorsBinder(); (in Global.asax.cs) but it did not work for me.

Implementation is not exactly the same like in the above link provided but overall it is same.

@{

Html.EnableClientValidation();

Html.EnableUnobtrusiveJavaScript();

    var grid = Html.DevExpress().GridView(settings => {

        settings.Name = "GridView1";

        settings.KeyFieldName = "StudentId";

        settings.CallbackRouteValues = new { Controller = "CustomBinding", Action = "MyGridViewPartial" };

        settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "CustomBinding", Action = "GridView1PartialAddNew" };

        settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "CustomBinding", Action = "GridView1PartialUpdate" };

        settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "CustomBinding", Action = "GridView1PartialDelete" };

        settings.SettingsEditing.Mode = GridViewEditingMode.EditFormAndDisplayRow;
        settings.SettingsBehavior.ConfirmDelete = true;

        settings.SettingsPager.PageSize = 20;


        settings.CommandColumn.Visible = true;
        settings.CommandColumn.ShowNewButton = true;
        settings.CommandColumn.ShowDeleteButton = true;
        settings.CommandColumn.ShowEditButton = true;

        settings.SettingsPager.PageSizeItemSettings.Visible = true;
        settings.SettingsPager.PageSizeItemSettings.Items = new string[] { "10", "20" };

        settings.SettingsCookies.Enabled = true;
        settings.SettingsCookies.CookiesID = settings.Name;
        settings.SettingsCookies.StoreColumnsVisiblePosition = true;
        settings.SettingsCookies.StoreColumnsWidth = true;
        settings.SettingsCookies.StoreFiltering = true;
        settings.SettingsCookies.StoreGroupingAndSorting = true;
        settings.SettingsCookies.StorePaging = true;

        settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
        settings.Settings.ShowColumnHeaders = true;
        settings.Settings.ShowFilterRow = true;
        settings.Settings.ShowFilterRowMenu = true;
        settings.Settings.ShowFooter = true;
        settings.Settings.ShowGroupButtons = true;
        settings.Settings.ShowGroupedColumns = true;
        settings.Settings.ShowGroupPanel = true;
        settings.Settings.ShowHeaderFilterButton = true;
        settings.Settings.ShowTitlePanel = true;
        settings.Settings.UseFixedTableLayout = true;

        settings.HtmlRowPrepared = (s, e) =>
        {
            MVCxGridView g = s as MVCxGridView;
            var index = g.PageIndex;

        };
        settings.CustomBindingRouteValuesCollection.Add(
       GridViewOperationType.Paging,
       new { Controller = "CustomBinding", Action = "MyPagingAction" }
   );

        settings.CustomBindingRouteValuesCollection.Add(
        GridViewOperationType.Sorting,
        new { Controller = "CustomBinding", Action = "MySortingAction" }
    );


        settings.SettingsAdaptivity.AdaptivityMode = GridViewAdaptivityMode.Off;
        settings.SettingsAdaptivity.AdaptiveColumnPosition = GridViewAdaptiveColumnPosition.Left;
        settings.SettingsAdaptivity.AdaptiveDetailColumnCount = 1;
        settings.SettingsAdaptivity.AllowOnlyOneAdaptiveDetailExpanded = false;
        settings.SettingsAdaptivity.HideDataCellsAtWindowInnerWidth = 0;


        settings.Columns.Add("StudentName");
        settings.Columns.Add("StudentAge");
        settings.Columns.Add("StudentGrade");
        settings.Columns.Add("StudentAddress");


        settings.CellEditorInitialize = (s, e) =>
        {
            ASPxEdit editor = (ASPxEdit)e.Editor;
            editor.ValidationSettings.Display = Display.Dynamic;

        };
            });
        if (ViewData["EditError"] != null){
        grid.SetEditErrorText((string)ViewData["EditError"]);
        }
}
@grid.BindToCustomData(Model).GetHtml()

Please suggest

Aucun commentaire:

Enregistrer un commentaire