function addColumn() { var itemSelected = getSelectedItemGrdTags(); //from first grid if (itemSelected == null) return; $(itemSelected).each(function (s, e) { //Set column name debugger; var count = columnCount +1; count = count + 1; columnCount++; e.ColumnName = "Columna_" + count; e.UUID = $.NewUUID(); //Add record $("#grdColumnsDataView").ejGrid("addRecord", e); }) } |
@(Html.EJ().Grid<DataViewColumnVM>("grdColumnsDataView") .Datasource(ds=>ds.Adaptor(Syncfusion.JavaScript.AdaptorType.JsonAdaptor)) .ToolbarSettings(tb => tb.ShowToolbar().ToolbarItems(tbi => { tbi.AddTool(Syncfusion.JavaScript.ToolBarItems.Edit); tbi.AddTool(Syncfusion.JavaScript.ToolBarItems.Update); tbi.AddTool(Syncfusion.JavaScript.ToolBarItems.Delete); tbi.AddTool(Syncfusion.JavaScript.ToolBarItems.Cancel); })) .AllowGrouping() .EditSettings(e => e.AllowAdding(true).AllowEditing(true).AllowDeleting(true)) .ShowStackedHeader() .StackedHeaderRows(row => { row.StackedHeaderColumns(column => { column.HeaderText("Valores de salida").Column(col => { col.Add("OutputValue"); col.Add("GroupByOperator"); }).Add(); column.HeaderText("Desfase temporal").Column(col => { col.Add("OffsetValue"); col.Add("OffsetUnit"); }).Add(); }).Add(); }) .Columns(c => { c.Field("UUID").IsPrimaryKey(true).IsIdentity(true).HeaderText("Id").Width(50).AllowEditing(false).Visible(true).Add(); c.Field("ColumnName").AllowEditing(true).HeaderText("Columna").Add(); c.Field("ColumnNameByType").HeaderText("Variable").AllowEditing(false).Add(); c.Field("ItemType").HeaderText("Tipo").AllowEditing(false) .ForeignKeyField("Id").ForeignKeyValue("Name").DataSource(@Model.DataViewItemTypes).Add(); c.Field("OutputValue").HeaderText("Valor de salida") .ForeignKeyField("Id").ForeignKeyValue("Name").DataSource(@Model.OutputValues).Add(); c.Field("GroupByOperator").HeaderText("Agrupar por") .ForeignKeyField("Id").ForeignKeyValue("Name").DataSource(@Model.GroupingOperators).Add(); c.Field("OffsetValue").HeaderText("Valor").Add(); c.Field("OffsetUnit").HeaderText("Unidades") .ForeignKeyField("Id").ForeignKeyValue("Name").DataSource(@Model.TimeUnits).Add(); }) /// .ScrollSettings(s => s.Height("110%")) .AllowScrolling(true) .AllowResizing(true) ) |
$.NewUUID = function createUUID() { var s = []; var hexDigits = "0123456789abcdef"; for (var i = 0; i < 36; i++) { s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1); } s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010 s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01 s[8] = s[13] = s[18] = s[23] = "-"; var uuid = s.join(""); console.log(uuid); return uuid; } |
<first grid> @(Html.EJ().Grid<GridUUIDgenerator.OrdersView>("FlatGrid") .Datasource((IEnumerable<object>)ViewBag.datasource) // <code something> /// .Columns(col => { col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("CustomerID").HeaderText("Customer ID").Width(80).Add(); col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).Width(75).Add(); col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(75).Format("{0:C}").Add(); col.HeaderText("Employee Details").Commands(command => { command.Type("detail") .ButtonOptions(new Syncfusion.JavaScript.Models.ButtonProperties() { Text = "Details", Width = "100px", Click = "addColumn" }).Add(); }) .IsUnbound(true) .TextAlign(TextAlign.Left) .Width(150) .Add(); })) <second Grid> @(Html.EJ().Grid<object>("Grid") .Datasource((IEnumerable<object>)ViewBag.datasource1) .AllowScrolling() .AllowPaging() /*Paging Enabled*/ .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); }) .ToolbarSettings(toolbar => { toolbar.ShowToolbar().ToolbarItems(items => { items.AddTool(ToolBarItems.Add); items.AddTool(ToolBarItems.Edit); items.AddTool(ToolBarItems.Delete); items.AddTool(ToolBarItems.Update); items.AddTool(ToolBarItems.Cancel); }); }) .Columns(col => { col.Field("UUID").IsPrimaryKey(true).IsIdentity(true).HeaderText("UUID").Width(50).AllowEditing(false).Visible(true).Add();
col.Field("ColumnName").AllowEditing(true).HeaderText("Columname").Add();
})) <add record into the second grid> function addColumn() { var itemSelected = getSelectedItemGrdTags(); //from first grid if (itemSelected == null) return;
$(itemSelected).each(function (s, e) { //Set column name debugger; var columnCount = 0; var count = columnCount + 1; count = count + 1; columnCount++;
e.ColumnName = "Columna_" + count; e.UUID = $.NewUUID(); //Add record $("#Grid").ejGrid("addRecord", e);
}) } |
If you still face the same issue, please share the following details,
1) Essential studio version details.
2) Have you confirmed isPrimarykey is enabled in UUID field in second Grid also?
3) Any script error throws in console while editing a second grid? If yes, provide the screenshot of that?
4) Share an issue reproducible sample.
Regards,
Venkatesh Ayothiraman.
@(Html.EJ().Grid<object>("Grid") .AllowScrolling() .AllowPaging() /*Paging Enabled*/ .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); }) .ToolbarSettings(toolbar => { toolbar.ShowToolbar().ToolbarItems(items => { items.AddTool(ToolBarItems.Add); items.AddTool(ToolBarItems.Edit); items.AddTool(ToolBarItems.Delete); items.AddTool(ToolBarItems.Update); items.AddTool(ToolBarItems.Cancel); }); }) .Columns(col => { col.Field("UUID").HeaderText("UUID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("OrderID").HeaderText("Order ID").TextAlign(TextAlign.Right).Width(75).Add(); col.Field("CustomerID").HeaderText("Customer ID").Width(80).Add(); col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).Width(75).Add(); col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(75).Format("{0:C}").Add(); })) |
function getSelectedItemGrdTags() { var s = $("#FlatGrid").ejGrid("getSelectedRecords"); // var s = { UUID: "UUID", ColumnName: "ColumnName" } return s; } |
<script> function addColumn() { var itemSelected = getSelectedItemGrdTags(); //from first grid if (itemSelected == null) return; itemSelected = $.extend(true,[], [], itemSelected); $(itemSelected).each(function (s, e) { //Set column name var columnCount = 0; var count = columnCount + 1; count = count + 1; columnCount++; e.ColumnName = "Columna_" + count; e.UUID = $.NewUUID(); //Add record $("#Grid").ejGrid("addRecord", e); }) } function getSelectedItemGrdTags() { var s = $("#FlatGrid").ejGrid("getSelectedRecords"); return s; } |