1

我正在尝试以百分比设置 DevExpress 网格的宽度,但该属性对我不可用,就像在我看到的每个示例中一样。我正在使用 MasterDetail 网格 Devexpress 12.1 版

settings.Width = Unit.Percentage(100);

如何将整个网格的宽度属性设置为 100%,然后如何为列设置相同的属性。这是我的网格

@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()
4

1 回答 1

4

好的,所以我找到了答案。为了解决这个问题,我在 cshtml 页面的顶部添加了这个 using 语句。

@using System.Web.UI.WebControls;
于 2012-11-15T00:45:06.800 回答