private GridViewSettings GetGridViewSettings()
{
var settings = new GridViewSettings();
settings.Name = "gvCountry";
settings.KeyFieldName = "ID";
settings.CallbackRouteValues = new { Controller = "Master", Action = "CountryPartial" };
settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
settings.SettingsPager.PageSize = 10;
settings.ControlStyle.Paddings.Padding = System.Web.UI.WebControls.Unit.Pixel(0);
settings.ControlStyle.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
settings.ControlStyle.BorderBottom.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);
settings.Settings.ShowFilterRow = true;
settings.Settings.ShowGroupPanel = false;
settings.Settings.ShowFilterBar = GridViewStatusBarMode.Visible;
settings.SettingsSearchPanel.Visible = false;
settings.SettingsBehavior.ConfirmDelete = true;
settings.Settings.ShowStatusBar = GridViewStatusBarMode.Hidden;
settings.Settings.ShowFooter = false;
settings.Styles.AlternatingRow.Enabled = DevExpress.Utils.DefaultBoolean.True;
settings.Enabled = true;
settings.CommandColumn.Visible = true;
settings.SettingsBehavior.AllowSelectByRowClick = true;
settings.CommandColumn.ShowNewButtonInHeader = true;
settings.CommandColumn.ShowDeleteButton = true;
settings.SettingsEditing.BatchEditSettings.StartEditAction = GridViewBatchStartEditAction.Click;
settings.SettingsEditing.BatchUpdateRouteValues = new { Controller = "Master", Action = "BatchUpdateCountry" }; //batch
settings.SettingsEditing.Mode = GridViewEditingMode.Batch; //batch
settings.SettingsEditing.BatchEditSettings.EditMode = GridViewBatchEditMode.Row;
settings.Columns.Add(columnsetting =>
{
columnsetting.FieldName = "COUNTRY_CODE";
columnsetting.Width = System.Web.UI.WebControls.Unit.Percentage(20);
});
settings.Columns.Add(columnsetting =>
{
columnsetting.FieldName = "COUNTRY_DESCRIPTION";
columnsetting.Width = System.Web.UI.WebControls.Unit.Percentage(40);
});
settings.Columns.Add(columnsetting =>
{
columnsetting.FieldName = "NATIONALITY";
columnsetting.Width = System.Web.UI.WebControls.Unit.Percentage(20);
});
settings.Columns.Add(column =>
{
column.Caption = "State";
column.FieldName = "COUNTRY_CODE";
column.Width = System.Web.UI.WebControls.Unit.Percentage(10);
column.ColumnType = MVCxGridViewColumnType.HyperLink;
HyperLinkProperties properties = column.PropertiesEdit as HyperLinkProperties;
properties.Text = "State";
properties.NavigateUrlFormatString = Url.Content("~/Master/State?CountryCode={0}");
column.EditFormSettings.Visible = DefaultBoolean.False;
column.Settings.AllowDragDrop = DefaultBoolean.False;
column.Settings.AllowSort = DefaultBoolean.False;
column.Settings.AllowAutoFilter = DefaultBoolean.False;
});
settings.ClientSideEvents.BeginCallback = "gridView_BeginCallback";
settings.ClientSideEvents.EndCallback = "gridView_EndCallback";
settings.CustomJSProperties = (s, e) =>
{
string records = "<records>";
var clientData = new Dictionary<int object="">();
MVCxGridView grid = s as MVCxGridView;
for (int i = 0; i < grid.VisibleRowCount; i++)
{
records += "<record grid.getrowvalues="" i="" id="\" name="\">";
}
records += "</record></int></records>";
if (access.CanUpdate == false)
{
for (int j = 0; j < grid.DataColumns.Count; j++)
{
clientData.Add(j, grid.DataColumns[j].FieldName);
}
}
else
{
clientData.Add(0, "COUNTRY_CODE");
}
e.Properties["cpRecords"] = Server.HtmlEncode(records);
e.Properties["cp_cellsToDisable"] = clientData;
};
settings.CellEditorInitialize = (s, e) =>
{
ASPxEdit editor = (ASPxEdit)e.Editor;
editor.ValidationSettings.Display = Display.Dynamic;
};
settings.ClientSideEvents.BatchEditStartEditing = "gridView_BatchEditStartEditing";
settings.ClientSideEvents.BatchEditEndEditing = "gridView_BatchEditEndEditing";
settings.ClientSideEvents.BatchEditRowValidating = "gridView_BatchEditRowValidating";
return settings;
}
No comments:
Post a Comment
Comments