Search code examples
jqueryjqgridjqgrid-asp.netfree-jqgrid

JQgrid custom inline edit format


Is it possible to have custom formater in inline edit cell? Well, this is my column formatter:

formatoptions: { decimalPlaces: 4, decimalSeparator: ",", thousandsSeparator: ".", defaultValue: " " }

Main problem is that separator in inline mode is "." and not "," and if user enters "242151,456" it returns 'NaN' but "25675.466" it is transfered in corresponding format. Need help :)


Solution

  • There are different ways to do this. For example you can modify the data entered by the user inside of saveRowValidation callback. For example, the demo https://jsfiddle.net/OlegKi/kj8y2nu9/ uses

    saveRowValidation: function (options) {
        var newData = options.newData;
        newData.amount = String(newData.amount).replace(",", ".");
        newData.tax = String(newData.tax).replace(",", ".");
        newData.total = String(newData.total).replace(",", ".");
        return true; // validation is successful
    }
    

    to replace , to .. The exact logic could be a little complex, but I think you could implement it inside of saveRowValidation in the same way.