Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Lagnajeet Sahu on Apr 03, 2009 01:14
open dhtmlx forum
issue with commas in text for addRow API function

Hi,

I am using licensed version of dhtmlx treegrid v 2.1. We are not using xml to create the treegrid.
We are sending the data in an array from the server side and creating the headers, rows , subrows , footer using the API functions.
For adding row we are using the "addRow" function

addRow(new_id, text, ind)
add row to the grid



File required:dhtmlxgrid.js
new_id - row ID, must be unique
text - row values, may be a comma separated list or an array
ind - index of new row, optional, row added to the last position by default


What if the cellvalue has a comma (,) this does not get escaped in the text parameter. I tried using

text = String(text).replace(/,/g,"\\,"); //doesnt work
text = String(text).replace(/,/g,"\,"); //doesnt work
text = String(text).replace(/,/g,"\\\,"); //doesnt work
Answer posted by Support on Apr 03, 2009 03:07
Instead of 
   grid.addRow(123,"a,b,c")
you can use 
   grid.addRow(123,["a","b","c"])
In such case values will be correctly added even if they have commas inside

Alternatively you can change delimiter sign to any other value ( grid.setDelimiter )
Answer posted by Lagnajeet Sahu on Apr 03, 2009 04:13
Thanks a TON !!