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'm trying to get to the underlying data of the webGrid in order to create a JSON string for use later.
I have no problem getting the column header names but can't get the value for each column for each row.
I'm using something like:
Public Shared Function GetWebJSONString(ByVal Dt As WebGrid) As String Dim count As Integer = Dt.RootTable.Columns.GetVisibleColumnsCount() Dim StrDc As String() = New String(count - 1) {} Dim HeadStr As String = String.Empty For i As Integer = 1 To count - 1 StrDc(i) = Dt.RootTable.Columns(i).Name HeadStr += ("""" & StrDc(i) & """ : """) + StrDc(i) + i.ToString() & "¾" & """," Next HeadStr = HeadStr.Substring(0, HeadStr.Length - 1) Dim Sb As New StringBuilder() For i As Integer = 0 To count - 1 Dim TempStr As String = HeadStr Sb.Append("{") For j As Integer = 1 To Dt.RootTable.Rows.Count - 1 Dim zzzz As String = Dt.RootTable.Rows.GetItem(j).ToString Dim zzzza As String = Dt.RootTable.GetUngrouppedRows().GetRowByKeyValue("2075246").Cells.GetNamedItem("CarrierName").Text.ToString() 'Dim rows As WebGridRowCollection = Dt.RootTable.GetUngrouppedRows() 'Dim keyValue As String = Dt.RootTable.GetUngrouppedRows().Item(j).KeyValue 'Dt.RootTable.GetUngrouppedRows().GetRowByKeyValue(keyValue).Cells.GetNamedItem("CarrierName").Text.ToString() 'Dim z As String = Dt.RootTable.GetUngrouppedRows().GetRowByKeyValue(keyValue).Cells.GetItem(j).ToString() 'TempStr = TempStr.Replace(Dt.RootTable.Columns(j).Name.ToString + j.ToString() & "¾", Dt.Rows(i)(j).ToString()) Next Sb.Append(TempStr & "},") Next Sb = New StringBuilder(Sb.ToString().Substring(0, Sb.ToString().Length - 1)) Return Sb.ToString() End Function
I've tried multiple ways to get the data but no seem to work! How can I get the following:
1. Total number of columns not just the visible columns
2. Get the keyValue of each row in the grid
3. The value for each column for each row in the grid
I need to get the data after the user has filtered and reduced the number of rows from the original query. This function runs froma Button click event.
Any help?
thanks
Hi John,
Sorry for the late reply. Based on your questions, I made a sample that has a button that gets the desired data you requested. The code behind is using c# though, but it does the job. Feel free to evaluate on the sample.
Best Regards,Erwin Sanders
function getWebGridData() { var WebGrid1 = wgGetGridById("WebGrid1"); var totalRows = WebGrid1.TotalRows; var sb = ''; for (var i = 0; i < totalRows; i++) { sb += '{'; var _Row = WebGrid1.RootTable.GetRow(i); var cells = _Row.GetCells(); sb += '"DOT_NUMBER" : "' + cells.GetNamedItem('DOT').Value + '", "PHY_LAT" : "' + cells.GetNamedItem("pLat").Value + '", "PHY_LONG" : "' + cells.GetNamedItem("pLong").Value + '", "TYPE" : "' + cells.GetNamedItem("AuditTypeDesc").Value + '"' ; sb += '},'; } sb = sb.substring(0, sb.length - 1); //alert(sb); return sb; }
Hello again John,
I've discussed your issue with our development team regarding your question about getting all the data in WebGrid without having to load all the rows, and unfortunately there's no way to do this at the moment.
However, you could do a client data binding through a WebService and get all the WebGrid data from the JavaScript for your JSON.
Hope this helps.
You are welcome, John. Should you find any other difficulties, we are here to help.
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