using addrecord duplicate row
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; } |
Thanks for contacting Syncfusion support.
We are unable to reproduce the issue. We have created a sample with two Grids. If we select a row and clicks the custom button inside the first Grid, then a new record will be added to the second Grid. For your convenience, we have created a sample and refer to the code sample.
Code Sample:
|
<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);
}) } |
1.Intially grid Render:
2. Now new record added into the second grid while select a row and clicked a custom button.
3.Now Edit the record.
Sample: http://www.syncfusion.com/downloads/support/directtrac/general/ze/GridUUIDgenerator-1181507400
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; } |
Then, try this sequence:
Attachment: GridUUIDgenerator_EDIT_25bad153.zip
Thanks for the update.
Yes, we were able to reproduce the issue, while adding the same records. Adding a record through clicking the custom button stores to the object. Now, clicking the same custom button stores the reference of the previous object value into new object. So, old UUID value is changed by newly generated UUID value. This is the reason for UUID value changed to new value while editing a record.
For your convenience, we have created a sample and refer to the code sample,
|
<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; } |
Sample:GridUUIDgenerator_EDIT_25bad153
Regards,
Venkatesh Ayothiraman.
Thanks for your feedback.
We have happy to hear that your requirement is achieved.
Thanks,
Venkatesh Ayothiraman.
- 5 Replies
- 2 Participants
-
DA David
- Feb 25, 2016 01:35 PM UTC
- Mar 1, 2016 06:18 AM UTC