Hi,
We are moving on to Infragistics 13.1. Please find the code below which we used to achieve 'copy' of a row at client side.
Please review and need your urgent suggestions on the snippet.
We are stuck up as igtbl_addNew doesnot seem to exist now.
Code snippet - Infragistics 7.3
function Copy(xmlRowData){ try { var theGrid = igtbl_getGridById(ManageItems.gridClientId); var copiedRow = igtbl_addNew(ManageItems.gridClientId, 0); var xmlDoc = jsAJAX.CreateXmlDocument(); xmlDoc.loadXML(xmlRowData); var rowData = xmlDoc.firstChild.firstChild; var rowCells = rowData.childNodes; for (var i = 0; i < rowCells.length; i++) { var cell = copiedRow.getCellFromKey(rowCells[i].nodeName); for (var j = 0; j < rowCells[i].attributes.length; j++) { switch (rowCells[i].attributes[j].nodeName) { case 'celltext': cell.setValue(rowCells[i].attributes[j].value); break; case 'cellvalue': var theCellElement = cell.getElement(); var theCheckbox = theCellElement.children[0].children[0]; if (rowCells[i].attributes[j].value == 'true') theCheckbox.checked = true; else theCheckbox.checked = false; break; case 'disabled': if (rowCells[i].nodeName.toLowerCase() == 'delete' || rowCells[i].nodeName.toLowerCase() == 'readonly') { var theCellElement = cell.getElement(); var theCheckbox = theCellElement.children[0].children[0]; if (rowCells[i].attributes[j].value == "true") theCheckbox.disabled = true; else theCheckbox.disabled = false; } if (rowCells[i].attributes[j].value == 'true') cell.setEditable(false); else cell.setEditable(true); break; case 'innerHTML': var theCellElement = cell.getElement(); var theNOBR = theCellElement.children[0]; theNOBR.innerHTML = rowCells[i].attributes[j].value; break; case 'TargetURL': var theCellElement = cell.getElement(); var theLink = theCellElement.children[0].children[0]; theLink.setAttribute('href', rowCells[i].attributes[j].value); break; case 'textAlign': document.getElementById(cell.Id).style.textAlign = rowCells[i].attributes[j].value; break; } } } } catch (e) {
}}
Hello,
I am checking about the progress of this issue. Please let me know If you need any further assistance on this.
If that column is really a read-only column then you cannot change its value. It's very hard to come up with a solution without having something real to work on, so can you please upload a sample project which you want us to make work for adding a new row in grid and just give your exact requirements on what you are trying to achieve so we can help you.
Its urgent! Please respond to the last two queries.
Awaiting your response.
Hi Petar,
What are the other options apart from Batch Update.
Cos it affects my other functionality, wherein i get a Úndo'option for my deleted row, which i dont need.
Please reply asap.
I enabled 'Batch Update' and was able to get through the error.
<asp:ScriptManagerProxy ID="ScriptManager1" runat="server"> </asp:ScriptManagerProxy> <asp:UpdatePanel ID="m_warpManageGrid" runat="server"> <ContentTemplate> <asp:Label runat="server" ID="lbl_m_grdManageItems"></asp:Label> <igtbl:WebDataGrid runat="server" ID="m_grdManageItems" AutoGenerateColumns="False" DataKeyFields="BOId" EnableAjax="False" EnableViewState="false" OnLoad="m_grdManageItems_Load" OnInit="m_grdManageItems_Init"> <Behaviors> <igtbl:Activation/> <igtbl:EditingCore BatchUpdating="true"> <Behaviors> <igtbl:RowAdding/> <igtbl:RowDeleting/> <igtbl:CellEditing/> </Behaviors> </igtbl:EditingCore> </Behaviors> </igtbl:WebDataGrid> </ContentTemplate> </asp:UpdatePanel>
-------------------------------------------------------------------
There is a check box column in my grid and i create it in Init function of WebdataGrid using the below code in code behind.
BoundCheckBoxField ReadOnly = new BoundCheckBoxField(true); ReadOnly.Key = c_sReadOnly; ReadOnly.Header.Text = ReadOnlyText(); ReadOnly.Width = Unit.Pixel(65); ReadOnly.CssClass = "CheckboxItem"; ReadOnly.CheckBox.CheckedImageUrl = "~/ig_res/Default/images/ig_checkbox_on.gif"; ReadOnly.CheckBox.UncheckedImageUrl = "~/ig_res/Default/images/ig_checkbox_off.gif"; this.m_grdManageItems.Columns.Add(ReadOnly);
---------------------------------------------------------------------
This is my copy function code (add row). But it throws exception when trying to set the checkbox value in the below code for 'Readonly' column in switch case 'cellvalue'.
.js
var theGrid = $find(gridClientId);
var rows = theGrid.get_rows(); var rowsLength = theGrid.get_rows().get_length(); var row = ["KeyValue", "BOId", "ComponentType", "Name", "Description", "Owner", "Alias", "Created", "LastUpdated", "ReadOnly","Rename", "Copy", "Delete"]; rows.add(row);
var lastRow = rows.get_row(rowsLength); var xmlDoc = jsAJAX_CreateXmlDocument(); xmlDoc.loadXML(xmlRowData); var rowData = xmlDoc.firstChild.firstChild; var rowCells = rowData.childNodes; for (var i = 0; i < rowCells.length; i++) { var cell = lastRow.get_cellByColumnKey(rowCells[i].nodeName); for (var j = 0; j < rowCells[i].attributes.length; j++) { switch (rowCells[i].attributes[j].nodeName) { case 'celltext': cell.set_value(rowCells[i].attributes[j].value); break; case 'cellvalue': var theCellElement = cell.get_element(); var theCheckbox = theCellElement.children[0].children[0]; if (rowCells[i].attributes[j].value == 'true') theCheckbox.checked = true; else theCheckbox.checked = false; break; case 'disabled': if (rowCells[i].nodeName.toLowerCase() == 'delete' || rowCells[i].nodeName.toLowerCase() == 'readonly') { var theCellElement = cell.get_element(); var theCheckbox = theCellElement.children[0].children[0]; if (rowCells[i].attributes[j].value == "true") theCheckbox.disabled = true; else theCheckbox.disabled = false; } if (rowCells[i].attributes[j].value == 'true') cell.setEditable(false); else cell.setEditable(true); break; case 'innerHTML': var theCellElement = cell.get_element(); theCellElement.innerHTML = rowCells[i].attributes[j].value; break; case 'TargetURL': var theCellElement = cell.get_element(); var theLink = theCellElement.children[0].children[0]; theLink.setAttribute('href', rowCells[i].attributes[j].value); break; case 'textAlign': document.getElementById(cell.Id).style.textAlign = rowCells[i].attributes[j].value; break; } } }
Please suggest me what iam missing.
I have a doubt that if something should be handled in below line for checkbox columns before passing this row to 'ádd' function.
var row = ["KeyValue", "BOId", "ComponentType", "Name", "Description", "Owner", "Alias", "Created", "LastUpdated", "ReadOnly","Rename", "Copy", "Delete"];
Please clarify and correct me.