jQuery UI Widgets Forums Grid Escaping cell values

This topic contains 3 replies, has 2 voices, and was last updated by  Dimitar 11 years, 7 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Escaping cell values #26172

    Arthur
    Member

    Hi,

    I’d like to escape user input before the value is actually written into the cell. How is it possible to achieve this?
    Im testing with the following string:
    alert(‘I am an alert box!’);
    When pasting this string into a cell the alert box pops up. I’d expect that the string is escaped and the pasted string is shown instead of the alert box being shown. Of course we also have server-side escaping, but I think its cleaner to escape the stuff also on client side and prevent that such code is actually interpreted.

    Regards,
    Arthur

    Escaping cell values #26242

    Dimitar
    Participant

    Hello Arthur,

    To achieve this, please use the cellbeginedit columns callback function. Here is an excerpt from the documentation on its use:

    cellbeginedit – sets a custom function which is called when a cell enters into edit mode. The Grid passes 3 parameters to it – row index, column data field and column type. The function can be used for canceling the editing of a specific Grid cell. To cancel the editing, the function should return false.

    { text: ‘Product’, columntype: ‘dropdownlist’, datafield: ‘productname’, width: 177,
    cellbeginedit: function (row, datafield, columntype) {
    if (row == 2)
    return false;
    }
    }

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Escaping cell values #26255

    Arthur
    Member

    Thx for your answer Dimitar. The problem with your advice is, that I do not have the user entered value at this point in time.
    What I want is to escape the user entered value before it is written into the cell.

    Appreciate any other advices or hints.

    Escaping cell values #26260

    Dimitar
    Participant

    Hi Arthur,

    If you wish to disable the editing of a cell, you should use the cellbeginedit callback function as shown in the demo Disable Editing of Rows.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.