ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: dbadmin on July 24, 2014, 02:36:03 am
-
Hi,
Is there a way to easily remove html characters when retrieving $( "#grid_array" ).pqGrid( "option" , "dataModel.data" )?
I put it into javascript variable and send it to PHP server side, where the problem occurs. (the way data is accessed: $dataArray[$i][0] )
Thanks!
-
there is no inbuilt method in pqgrid to remove HTML characters, you could take the help of this post.
http://stackoverflow.com/questions/822452/strip-html-from-text-javascript
I would also suggest to avoid HTML characters in grid data in the first place. dataModel.data should contain pure data and any HTML formatting should be done in column.render callback.
-
The problem is -- I do not put any html chars in the cells, a user just puts in some text, and sometimes <br> comes up or <span class="...">...</span> as a value. So my questions was how to avoid it?
-
What is the type of editor you are using?
-
editModel: {clicksToEdit: 1, saveKey: 13},
-
you haven't mentioned what kind of editor you are using.
If it's contenteditable, then any line break in text would appear as <br/> in the data.
If it's textbox or textarea, there won't be any HTML characters unless the user types raw HTML i.e., <br/>, <span> deliberately.
In any case you can clean the input before accepting it in data by implementing editor.getData callback.
As an example:
editor: {
type: "textarea",
attr: "rows=3",
getData: function (ui) {
//debugger;
var tmp = document.createElement("DIV");
tmp.innerHTML = ui.$cell.find(".pq-editor-focus").val();
return tmp.textContent || tmp.innerText || "";
}
}
-
I'm not specifying any "editor", based on assumption that there is a default one. Is the default editor not "textarea"?
Do I have to specify editor in each grid to solve the problem?