Batch edit strips HTML

4 posts, 0 answers
  1. Albert Shenker
    Albert Shenker avatar
    579 posts
    Member since:
    Mar 2004

    Posted 27 Dec 2016 Link to this post

    I believe I found a limitation in the batch editing feature which doesn't appear to be documented anywhere. I have been able to replicate this using your online batch editing demo at http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/batch-editing/defaultcs.aspx

    The limitation has to do with making changes to text fields that include html markup. For example, in your demo, if I click to batch edit the ProductName column and enter something like '<b>My Product Name</b>', the text is saved properly upon saving the batch edit, and the product name is displayed in bold in the grid. However, if I then go to edit this field again, the full html text is not shown in the editor... only 'My Product Name'. Saving this obviously strips the <b> tags.

    It seems the editor is not able to render these tags. I wouldn't expect a simple text field editor to display rich text, but I would expect it to display the actual text as saved in the datasource (in this case '<b>My Product Name</b>'). I'm not sure why the editor strips the '<b>' and '</b>' tags. I tried using the encoded values for these tags (like &lt; and &gt;) and the same thing happens. This basically means that one cannot use batch editing when storing html values.

    You may want to emphasize this limitation somewhere so people don't waste there time trying to implement batch-editing solutions for html content. Also, is there a particular reason for this limitation? I can see how stripping script tags would make sense from a security standpoint, but I'm not really sure about other valid html. Is this something that won't be a limitation in the future?

     

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2379 posts

    Posted 29 Dec 2016 Link to this post

    Hi Albert,

    Entering tags in an input control is generally not allowed by the framework. The Request Validation feature considers any code wrapped between tags with < and > characters to be potentially dangerous. You can find more information regarding Request Validation in the following article.


    With that said, if you would like to enter HTML in the RadGrid I would recommend using GridHTMLEditorColumn. It enables you to submit HTML in the grid out of the box. Check out the article below that described the GridHTMLEditorColumn in more detail:



    Regards,
    Viktor Tachev
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Albert Shenker
    Albert Shenker avatar
    579 posts
    Member since:
    Mar 2004

    Posted 29 Dec 2016 in reply to Viktor Tachev Link to this post

     

    I tried that column type. The RadEditor it renders doesn't appear to raise the GridBatchEditCellValueChangingEvent when you blur away from it. KeyboardNavigation also appears to be broken when using this column type. When the editor is displayed, it does not have focus, unlike the textbox equivalent. If a user hits TAB without the editor being focused, there is a javascript error.

     

    For what its worth, I rant into similar issues when trying to use a RadEditor in a template column

  4. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2379 posts

    Posted 30 Dec 2016 Link to this post

    Hello Albert,

    The RadEditor is a complex control that provides rich functionality. It is expected for it to behave differently than the regular TextBox control that is rendered for a GridBoundColumn.

    If you prefer to use the simple editors you can set the HtmlEncode property for the column to true.


    <telerik:GridBoundColumn DataField="SomeField" HeaderText="Header text" UniqueName="Name" HtmlEncode="true">
    </telerik:GridBoundColumn>

    Note that in this scenario you should also turn off validation for the page as described in the thread below:


    Regards,
    Viktor Tachev
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top