Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1615
WebSlider inside WebDataGrid
posted

What is the best way to have a web slider within WebDataGrid that can cause an event to recalculate a value in another column?

Parents
  • 8421
    Suggested Answer
    posted

    Hello Aleksandr,

    What you can do is add the WebSlider to the contents of a TemplateDataField and use its ValueChanged event to modify the other cells. To do this you'll need to be able to access the row that contains the updated slider. A simple approach would be to add a hidden field to the template that contains the row's data key value. You can then get the value of the hidden field and use that to get the row. From the row you can then access the cell you want to update and modify its value:

    function slider_valueChanged(sender, eventArgs) {
        var grid = $find("<%= grid.ClientID %>");
        
        var rowID = sender.get_element().parentNode.querySelector(".rowID").value;
        var row = grid.get_rows().get_row(rowID);

        row.get_cellByColumnKey("Value").set_value(eventArgs.get_newValue());

        // Needed to make sure that the RowUpdating server event fires as expected
        grid.get_behaviors().get_activation().set_activeCell(row.get_cellByColumnKey("ValueSlider"));
    }

    I have attached the sample I used to verify this approach. Please let me know if you have any questions or concerns.

    WDGWithSlider.zip
Reply Children