Looking at the cell edit template, and I'm not sure how to do the .Edit part in VB.
https://ej2.syncfusion.com/aspnetmvc/documentation/grid/edit/#cell-edit-template
col.Field("OrderDate").HeaderText("Ship Name").Format("yMd").Edit(new { create = "create", read = "read", destroy = "destroy", write = "write" }).Width("150").Add();Any advice would be helpful!
|
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.DataSource).Columns(col =>{
col.Field("OrderID").HeaderText("Order ID").Width("150").IsPrimaryKey(true).Add();
col.Field("ShipCity").HeaderText("Ship City").Width("150").Add();
col.Field("OrderDate").HeaderText("Order Date").Format("yMd").Edit(new { create = "create", read = "read", destroy = "destroy", write = "write" }).Width("150").Add();
col.Field("CustomerID").HeaderText("CustomerID").Width("150").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Left).Add();
}).AllowSorting().AllowPaging().PageSettings(page => page.PageSize(8)).AllowSorting().EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Normal); }).Toolbar(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" }).Render()
<script>
var elem;
var dObj;
function create(args) { // Input element is created and returned for appending the DatePicker control
elem = document.createElement('input');
return elem;
}
function write(args) {//It is used to create the custom component or assign default value at the time of editing
dObj = new ej.calendars.DatePicker({ //DatePicker
value: new Date(args.rowData[args.column.field]),
placeholder: 'Select DateTime'
});
dObj.appendTo(elem);
}
function destroy() { //destroy function is used to destroy the component.
dObj.destroy();
}
function read(args) { //read function is used to read the value from component at time of save.
return dObj.value;
}
</script>
|
Hey, so yeah, I linked to that article too!
Apparently the real answer to how to do this is like this:
.Edit(New With {.create = "create", .read = "read", .destroy = "destroy", .write = "write"})
See, the C# version of
.Edit(new { create = "create", read = "read", destroy = "destroy", write = "write" })doesn't work in the VB.net version of ASP.net MCV.
Thanks for trying.
|
@Html.EJS().Grid("Grid").DataSource(Model).AllowPaging().Columns(Sub(col)
col.Field("OrderID").HeaderText("OrderID").IsPrimaryKey(True).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("120").Add()
col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add()
col.Field("OrderDate").HeaderText("Order Date").Format("yMd").Edit(New With { //define the code in vb.net syntax
.create = "create",
.read = "read",
.destroy = "destroy",
.write = "write"
}).Width("150").Add()
col.Field("Freight").HeaderText("Freight").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("120").Format("C2").Add()
End Sub).EditSettings(Sub(edit)
edit.AllowEditing(True)
edit.AllowAdding(True)
edit.AllowDeleting(True).Mode(Syncfusion.EJ2.Grids.EditMode.Normal)
End Sub).Render();
|