Is it possible to create a content and edit template to be inserted within a GridViewTemplateColumn so that one can reuse it and not repeatedly insert the templates into their html?
I have around 15 columns that all need similar functionality (Having text during content phase and a multiline textbox in edit) and it works fine by using a template column.
However, if I want to make changes to the templates, i'll need to change them all.
I've tried everything that I can think of to get this to work from creating a custom control to extending the template column but I may just not know enough about DotVVM to do it.
Any help would be greatly appreciated.
Solved! Solution below.
public class MultiLineTextColumn : GridViewTextColumn
{
public override void CreateEditControls(IDotvvmRequestContext context, DotvvmControl container)
{
var textBox = new TextBox();
textBox.FormatString = FormatString;
textBox.ValueType = ValueType;
textBox.SetBinding(TextBox.TextProperty, GetValueBinding(ValueBindingProperty));
textBox.Type = TextBoxType.MultiLine;
container.Children.Add(textBox);
}
}
In DotvvmStartup.cs
config.Markup.Controls.Add(new DotvvmControlConfiguration
{
TagPrefix = "cc",
Namespace = "Project.Controls",
Assembly = "Project"
});
You can create your own column type.
Create a class which inherits from GridViewColumn
.
Override CreateControls
, CreateEditControls
and CreateInsertControls
and build the control tree inside the cell.
If you wan to make a multi-line edit cell, you can modify the default GridViewTextColumn - just set the Type
to MultiLine
in the CreateEditControls
method.
DotvvmStartup
.