how to implement uppercase conversion in jqgrid

为君一笑 提交于 2019-12-02 04:28:08

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.

try:

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

or

$(document).ready(function(){    
   var strVal = 'lowerCase!!' ;  
   alert(strVal.toUpperCase()); 
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!