Hello,
I have a grid for my ASP.NET Core Razor page, and have it bound to the Model object.
In the interest of saving horizontal space, and for readability, we would like to split some cells to show Start date / End date in one cell, rather than have two columns for this data. Both data should be editable.
Is this possible?
Thanks
I believe this is possible, but with some effort. To begin, the "display" of both values in one field can be done with a client template. Here is one approach (certainly not the only one). Let's break this down...
First, see the example of using a "custom editor." In this example, you see a view model ("ProductViewModel.cs) with a "UIHint." (To view in this example, click "View Source" then on the tab for "ProductViewModel.cs.")
On the property "CategoryViewModel" you will see [UIHint("ClientCategory")]. The "CategoryViewModel" (found at the bottom of the file "ProductViewModel.cs") has two properties: "CategoryID" and "QuantityPerUnit."
Essentially what this defines is a property that the Grid uses that is in itself, a data model. You can make a model of your own which contains a start date and an end date.
Next, "UIHint".... Note that the attribute has parens with the value "ClientCategory."
This data attribute indicates a custom "Editor" to be used for your data model. In the example see the source file "ClientCategory.cshtml". What the UIHint is doing is it says to use the custom editor "ClientCategory.cshtml" with the property "CategoryViewModel" when in edit mode.
You can create an editor of your own that has two date selectors.
There is obviously more steps beyond this. But I hope it gives you some ideas.