Replace character in string on create/update
Replace character in string on create/update
peterbrowne
Posts: 314Questions: 54Answers: 0
in Editor
I want to replace semicolons and colons with their Hex Code equivalents on create and update in the edit functions. How do I do that?
Answers
I have tried:
```columns: [ {
data: "program_outcome.program_outcome",
render: function (data, type, row) {
switch(data) {
case ';':
return ';';
break;
case ':':
return ':';
break;
}
},
},``
But I just get:
DataTables warning: table id=program_outcome_table - Requested unknown parameter 'program_outcome.program_outcome' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4
The rendering function there will change the data when displayed in the DataTable. It won't effect what is edited in Editor or the data saved to the database.
In order to answer your question accurately, I think I'll need a little more information. For example, do you want the user to edit the data normally, but when saved it should use hex values in the database? If so, a set formatter would be the way to do it.
Allan
Thanks Allan, That sounds like the way to do it, but I may need some more help to get it working. So where:
entered value is a semi colon then substitute
;
entered value is a colon then substitute
:
That's the semi-colon one. You can add another replace for the colon. That's today's homework
Out of interest - why?
Allan