v11.1, dotnet v4.
I have a webDataGrid with AutoGenerateColumns. (At runtime I bind it to the results of a crosstab query.)
I want to set most, or optionally all, columns to recognise a newline. I can provide the newline in the data either as CR+LF or as <br/>, but have been unable to figure out how to set EnableMultiLine and/or HtmlEncode.
I'd prefer to do it server-side, immediately after .DataBind(), but would accept a client-side solution. How?
Hello,
I would suggest you to set HtmlEncode to false for the required columns. Then you should handle manually the RowUpdating event. From the event arguments you can get the values from the row being updated. If there is a tag in some of the values, it would be represented like "\r\n" sequence in e.Values collection. So you should replace this with and use the new string to directly update the database. Also, you should set AutoCRUD=”false” for the EditingCore behavior and set e.Cancel = true to cancel the default update in RowUpdating event handler.
If you have any questions, please don’t hesitate to ask.
Thanks for the suggestion.
This is display-only, there's no CRUD.
My question is: How do I set HtmlEncode to false on the columns? The columns don't exist at design time.
oops, no, that doesn't work.
You can set the HtmlEncode property of a column on Initialize client-side event:
grid.get_columns().get_column(1)._htmlEncode = false;
That's getting closer. How do I iterate through an unknown number of columns?
This hasn't worked (ineffective, doesn't actually get the column)
for (col in sender.get_columns()) { col._htmlEncode = false; }
nor (count() is undefined):
for (i = 0; i < sender.get_columns().count(); i++ ) { sender.get_columns.get_column(i)._htmlEncode = false; }
Hi,
I would suggest you to modify your code like this:
for (i=0; i < sender.get_columns().get_length(); i++) ...
Let me know if you have any other questions.
Thanks.
Putting it together, I embedded CR and Newline characters, and used:
function grid_Initialize(sender, eventArgs) { for (i = 0; i < sender.get_columns().get_length(); i++) { sender.get_columns().get_column(i)._htmlEncode = true; sender.get_columns().get_column(i)._enableMultiline = true; } }
I'm glad you managed to solve your issue.
Don't hesitate to ask if you have other questions or concerns.