首页 新闻 会员 周边 捐助

在MVC.DevExpress 的GridView编辑列中如何嵌套

0
悬赏园豆:5 [已关闭问题] 关闭于 2016-05-22 13:42

@using ProperGSMViewModel
@using DevExpress.Data.Linq
@using DevExpress.Web.Mvc
@using DevExpress.Web.Mvc.UI
@using DevExpress.Web.ASPxHtmlEditor;

@model ThingsViewModel

 


@{
Html.DevExpress().GridView(s =>
{
s.Name = "GridViewGallery";
s.KeyFieldName = "ID";

s.SettingsEditing.ShowModelErrorsForEditors = true;
s.SettingsBehavior.ConfirmDelete = true;

s.CallbackRouteValues = new { Controller = "Home", Action = "ThingPartial" };
s.SettingsEditing.UpdateRowRouteValues = new { Controller = "Home", Action = "ThingEditPartial" };
s.SettingsEditing.AddNewRowRouteValues = new { Controller = "Home", Action = "ThingEditPartial" };
s.SettingsEditing.DeleteRowRouteValues = new { Controller = "Home", Action = "ThingDeletePartial"};
s.SettingsEditing.Mode = GridViewEditingMode.EditForm;
s.SettingsDataSecurity.AllowDelete = true;

s.CommandColumn.Visible = true;
s.CommandColumn.ShowEditButton = true;
s.CommandColumn.ShowCancelButton = true;
s.CommandColumn.ShowNewButtonInHeader = true;
s.CommandColumn.ShowDeleteButton = true;


s.Columns.Add(settings =>
{
settings.Name = "coTitle";
settings.FieldName = "Title";
settings.EditFormSettings.Visible = DefaultBoolean.True;
settings.Settings.AutoFilterCondition = AutoFilterCondition.Contains;
settings.ColumnType = MVCxGridViewColumnType.TextBox;
TextBoxProperties properties = (TextBoxProperties)settings.PropertiesEdit;
});

s.Columns.Add(settings =>
{
settings.Name = "coTypeID";
settings.FieldName = "TypeID";
settings.Caption = "Type";//列的标题
settings.EditFormSettings.Visible = DefaultBoolean.True;
settings.ColumnType = MVCxGridViewColumnType.ComboBox;
ComboBoxProperties properties = (ComboBoxProperties)settings.PropertiesEdit;//下拉列表的属性
properties.DataSource = Model.ProperTypeLookUpData;//下拉列表的数据源
properties.TextField = "TypeName";//显示在下拉列表的数据
properties.ValueField = "ID";//数据的主键
properties.ValueType = typeof(string);//下拉列表数据的类型
properties.ValidationSettings.RequiredField.IsRequired = true;//是否为必填字段

});

s.Columns.Add(settings =>
{
settings.Name = "coContent";
settings.FieldName = "Content";

//settings.SetNestedContent(() =>
//{
// Html.RenderPartial("ProductWorldPartial", Model);
//});

settings.SetDetailRowTemplateContent(c =>
{
Html.RenderAction("RemoteClassPartial", new { LcID = DataBinder.Eval(c.DataItem, "LcID") });
});

 

红色部分报错,不知道怎么将一个World文档类型的分部视图嵌套到表格中。
});

 

s.Columns.Add(settings =>
{
settings.Name = "coDate";
settings.FieldName = "Date";
settings.EditFormSettings.Visible = DefaultBoolean.True;
settings.ColumnType = MVCxGridViewColumnType.DateEdit;

});

s.Columns.Add(settings =>
{
settings.Name = "coPath";
settings.FieldName = "Path";
settings.Settings.AutoFilterCondition = AutoFilterCondition.Contains;
settings.ReadOnly = true;
settings.SetDataItemTemplateContent(cell =>
{
ViewContext.Writer.Write(string.Format("<a href=\"{0}\" target=\"_blank\">{1}</a>", Url.Content(cell.Text), cell.Text));
});
settings.ColumnType = MVCxGridViewColumnType.TextBox;
TextBoxProperties properties = (TextBoxProperties)settings.PropertiesEdit;
properties.MaxLength = 100;
properties.ClientInstanceName = "TextBoxPath";//jQuery中所需要的名称
properties.ValidationSettings.RequiredField.IsRequired = true;
});

s.Columns.Add(settings =>
{
settings.Index = 5;
settings.Name = "coUploadControl";
settings.Caption = "图片上传";
settings.Visible = false;
settings.Settings.AllowAutoFilter = DefaultBoolean.False;
settings.ColumnType = MVCxGridViewColumnType.Default;
settings.EditFormSettings.VisibleIndex = 5;
settings.EditFormSettings.Visible = DefaultBoolean.True;
settings.EditFormSettings.ColumnSpan = 2;
settings.SetEditItemTemplateContent(c =>
{
Html.DevExpress().UploadControl(uploadsettings =>
{
uploadsettings.Name = "PathUploadControl";
uploadsettings.CallbackRouteValues = new { Controller = "Home", Action = "CallbacksUpload" };
uploadsettings.ShowUploadButton = true;
uploadsettings.ShowProgressPanel = true;
uploadsettings.UploadMode = UploadControlUploadMode.Auto;
uploadsettings.ValidationSettings.Assign(ProperGSM.FileUploadControlHelper.ImageUploadValidationSettings);
uploadsettings.ClientSideEvents.FileUploadComplete = "UploadControlCallback";//文件上传完成调用SCRIPT
}).Render();
ViewContext.Writer.Write("<div style=\"margin: 5px 0;\">类型:jpg/png/gif 最大文件大小: 2MB</div>");
});
});

s.Settings.ShowFilterRow = true;
s.Settings.ShowFilterRowMenu = true;
s.Settings.ShowFilterRowMenuLikeItem = true;
s.Settings.ShowFilterBar = GridViewStatusBarMode.Visible;
s.Styles.AlternatingRow.Enabled = DefaultBoolean.True;

s.Width = System.Web.UI.WebControls.Unit.Percentage(100);

s.SettingsBehavior.AutoFilterRowInputDelay = 2000;

s.SettingsPager.Position = System.Web.UI.WebControls.PagerPosition.Bottom;
s.SettingsPager.FirstPageButton.Visible = true;
s.SettingsPager.LastPageButton.Visible = true;
s.SettingsPager.PageSizeItemSettings.Visible = true;

}).BindToLINQ("", "", new EventHandler<LinqServerModeDataSourceSelectEventArgs>((s, e) =>
{
e.KeyExpression = "ID";
e.QueryableSource = Model.Source;
})).GetHtml();
}

谢梦兮的主页 谢梦兮 | 初学一级 | 园豆:190
提问于:2016-03-06 13:53
< >
分享
所有回答(1)
0
//表格中嵌套World文档
 s.Columns.Add(settings =>
            {
                settings.Name = "coContent";
                settings.FieldName = "Content";
                settings.EditFormSettings.ColumnSpan = 2;
                settings.EditFormSettings.Visible = DefaultBoolean.True;
                settings.Settings.AutoFilterCondition = AutoFilterCondition.Contains;
                settings.ColumnType = MVCxGridViewColumnType.Memo;
                MemoProperties properties = (MemoProperties)settings.PropertiesEdit;
                properties.Height = 50;
 
                settings.SetEditItemTemplateContent(m =>
                {
                    //查询一行数据
                    ThingViewModel vm = m.Grid.GetRow(m.VisibleIndex) as ThingViewModel;
                    if (vm == null)
                    {
                        //新增时
                        ThingViewModel vms=new ThingViewModel();
                        Html.RenderPartial("ContentWorldPartial",vms);
                    }
                    else 
                    { 
                 //编辑时
                    Html.RenderPartial("ContentWorldPartial",vm);
                    }
                });
 
            });
谢梦兮 | 园豆:190 (初学一级) | 2016-05-22 13:40
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册