iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
I have a Server-Side Event AddRow where I modify a DataRow Value.
I have tried retrieving the Value Client-Side in the OnAfterAdd Event but the rowObject Cells do not have the value yet. I do see it in the xmlResponseObject.
What is the best way to get this Value Client-Side?
I don't know if it matters, but this WebGrid Column for this value will not be Visible.
Thanks,
Doug
Other suggestion would be to hold the value you wish to process in the hidden field during AddRow server side event.
Here is the snippet to set the hidden field during AddRow server side event, in this example the field ID has been known, 5, and the hidden column will have the value "Custom-Val":
HiddenField1.Value = "5;Custom-Val";wgTest.ClientAction.RenderControl(HiddenField1);
Here is the snippet to retrieve the hidden field during OnAfterAdd client side event:
<script language="javascript" type="text/javascript"> function wgTest_OnAfterAdd(controlId, tblName, rowObject, xmlResponseObject) { setTimeout(function() { var fieldVal = document.getElementById('HiddenField1').value; var valComp = fieldVal.split(";"); alert(valComp[0] + " " + valComp[1]); }, 10); return true; }</script>
Declaration of the hidden field:
<asp:HiddenField ID="HiddenField1" runat="server" />
For such scenario, you could try parsing the XmlResponseObject using regex to retrieve the value you wanted. Here is the snippet to retrieve the value of the sixth td element in the XmlResponse object during OnAfterAdd client side event:
function wgTest_OnAfterAdd(controlId, tblName, rowObject, xmlResponseObject){ var wgTest = ISGetObject(controlId); var text = ISXml.GetNodes(xmlResponseObject, "//htmlRow")[0].text; var m = (new RegExp('(<td[\\w\\W]+?</td>){6}', "gm")).exec(text); var fieldVal = m[1].replace(new RegExp('(<[/]?td[\\w\\W]*?>|<[/]?nobr[\\w\\W]*?>)',"g"), ""); alert(fieldVal); return true;}
It does matter when the WebGrid Column is not Visible.
The value is no longer in xmlResponseObject.
Any other way or event to get this value?
If the column is not visible, you could try using HiddenDataMember property.
For example you wish to retrieve the Custom field value during AfterAddRow client side event. Here is the snippet of the AfterAddRow client side event handler:
function wgTest_OnAfterAdd(controlId, tblName, rowObject, xmlResponseObject){ var wgTest = ISGetObject(controlId); var rowID = rowObject.Cells.GetNamedItem("ID").Value setTimeout(function() { var tempVal = wgTest.RootTable.GetRowByKeyValue(rowID).GetCell("ID").CellElement.getAttribute("Custom"); alert(tempVal); }, 10); return true;}
Here is the snippet to declare the Custom hidden data member in the column ID:
<ISWebGrid:WebGridColumn Bound="true" EditType="TextBox" Name="ID" DataMember="ID" HiddenDataMember="Custom"></ISWebGrid:WebGridColumn>
Hi,
That solution has some problems:
1. As previous mentioned in this thread, "rowObject Cells do not have the value yet" and in my case the ID would be the Primary AutoIncrement Column. In this case I would have to get it from the XmlResponse.
2. Since in my case, the ID is also not a visible WebGrid Column, I can not get it from the XmlResponse, hence it will not be available for the setTimeout function.
Any other ideas?
That works.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname