Skip to content Skip to sidebar Skip to footer

How To Implement Uppercase Conversion In Jqgrid

Producr codes can contain only uppercase charcters. If lowercase characters are enterd, jqgrid does not convert them to upper case, there is not such option. How to force uppercase

Solution 1:

First of all you can use CSS style text-transform: uppercase to display the data typed by the user in uppercase:

editoptions: { dataInit: function (el) { $(el).css('text-transform', 'uppercase'); }}

The setting will not change the data itself. So you have to make the corresponding modification additionally. In case of form editing you can use beforeSubmit. For example, let us you have column 'name' which you need to hold uppercase. Then you first add the setting of text-transform: uppercase in dataInit (see above) and add

beforeSubmit: function (postData) {
    postData.name = postData.name.toUpperCase();
    return [true, ''];
}

In case of inline editing there are no beforeSubmit callback function. so you can use serializeRowData if you have remote data:

serializeRowData: function (postData) {
    postData.name = postData.name.toUpperCase();
    return postData;
}

In case of usage editurl: 'clientArray' you can fix the data in aftersavefunc parameter of editRow and saveRow:

aftersavefunc: function (rowid) {
    var$grid = $(this),
        newName = $grid.jqGrid("getCell", rowid, 'name');
    $grid.jqGrid("setCell", rowid, 'name', newName.toUpperCase());
}

See the demo.

Solution 2:

try:

 $(document).ready(function(){
          $("div").text("lower case.");
          varUCASE =  $("div").text($("div").text().toUpperCase());
          alert(UCASE);
    });

or

$(document).ready(function(){    
   var strVal = 'lowerCase!!' ;  
   alert(strVal.toUpperCase()); 
});

Post a Comment for "How To Implement Uppercase Conversion In Jqgrid"