我正在尝试以百分比设置DevExpress网格的宽度,但该属性不适用于我,就像我看到的每个示例一样。我正在使用MasterDetail网格Devexpress版本12.1
settings.Width = Unit.Percentage(100);
如何将整个网格的width属性设置为100%,然后如何为colums设置相同的属性。这是我的网格
@Html.DevExpress().GridView(
settings => {
settings.Name = "masterGrid";
settings.CallbackRouteValues = new { Controller = "InwardsGoods", Action = "GridViewMasterPartial" };
settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "InwardsGoods", Action = "GridViewMasterAddNewPartial" };
settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "InwardsGoods", Action = "GridViewMasterUpdatePartial" };
settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "InwardsGoods", Action = "GridViewMasterDeletePartial" };
settings.KeyFieldName = "InwardsGoodsID";
settings.Columns.Add(column =>
{
column.FieldName = "CustomerID";
column.Caption = "Customer";
column.ColumnType = MVCxGridViewColumnType.ComboBox;
var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
comboBoxProperties.DataSource = Model.CustomersList;
comboBoxProperties.TextField = "CustomerName";
comboBoxProperties.ValueField = "CustomerID";
comboBoxProperties.ValueType = typeof(int);
});
settings.Columns.Add(column =>
{
column.FieldName = "CustomerReference";
column.Caption = "Customer Reference";
});
settings.Columns.Add(column =>
{
column.FieldName = "TimberShadeReference";
column.Caption = "TimberShade Reference";
});
settings.Columns.Add(column =>
{
column.FieldName = "DateReceived";
column.Caption = "Date Received";
column.PropertiesEdit.DisplayFormatString = "d";
});
settings.Columns.Add(column =>
{
column.FieldName = "Comment";
column.Caption = "Comment";
});
settings.SettingsDetail.AllowOnlyOneMasterRowExpanded = true;
settings.SettingsDetail.ShowDetailRow = true;
settings.CommandColumn.Visible = true;
settings.CommandColumn.NewButton.Visible = true;
settings.CommandColumn.DeleteButton.Visible = true;
settings.CommandColumn.EditButton.Visible = true;
settings.SetDetailRowTemplateContent(c =>
{
Html.RenderAction("GridViewDetailPartial", new { inwardsgoodsID = DataBinder.Eval(c.DataItem, "InwardsGoodsID") });
});
//TO OPEN THE FIRST EDITABLE ROW
//settings.PreRender = (sender, e) =>
//{
// ((MVCxGridView)sender).DetailRows.ExpandRow(0);
//};
}).Bind(Model.InwardsGoods).GetHtml()
答案 0 :(得分:4)
好的,我找到了答案。我为解决这个问题所做的是在cshtml页面的顶部我添加了这个using语句。
@using System.Web.UI.WebControls;