1

在网格中有一列,用户可以使用下拉菜单设置值。我在该列上调用了一个自定义验证。如果验证失败,它会显示带有选项值而不是选项文本的消息。如何将此值更改为文本?

<script language="javascript" type="text/javascript">
var i = 1;
var  lastSelection=0;
$(function()
{
     $("#curruntppeGridgrid").jqGrid({
            url:'getcostperformancecurreuntPPE',
            datatype: "json",
            jsonReader:{"repeatitems":false,unformat:Unformat_Select},
            colNames:[category], 
            colModel:[                  
                        {name:'category',index:'category',align:'center',editable: true, hidden: false, edittype: 'select',
                       editoptions: { multiple: false, value:catList},
                       editrules: {required:false,custom:true,custom_func:categorycheck}
                       }                   
                       ],
            cmTemplate:{sortable:false},
            width: eval('gridWidth()'),
            pgbuttons:false,
            pginput:false,
            viewrecords:false,
            //pager: '#curruntppeGridpager',
            toppager:true,
            multiselect:true,
            editurl: 'editsurveyppe',
            caption: currentPPE,
            //forceFit:true,
            hiddengrid:true,
            hidegrid:true,
            headertitles:true,
            postData: { appId: function() { return $('#selectApplication option:selected').val(); }
            },
            onHeaderClick : function(gridstate){

                if(gridstate == 'visible'){
                    $("#curruntppeGridgrid_toppager").show();
                }
                else{
                    $("#curruntppeGridgrid_toppager").hide();
                }

            },
            loadComplete: function() {
                $('#del_curruntppeGridgrid_top').removeClass('ui-state-disabled');//this is added to enable delete button after record reload
                if(jQuery('#curruntppeGridgrid').jqGrid('getGridParam','gridstate')!='visible')
                {
                    $("#curruntppeGridgrid_toppager").hide();
                }
                else{
                    $("#curruntppeGridgrid_toppager").show();
                }

            },
            afterInsertRow:function(){//this is added to disable delete button while adding record
                $('#del_curruntppeGridgrid_top').addClass('ui-state-disabled');
            }
            ,ajaxSelectOptions: { cache: false }

        });

        jQuery("#curruntppeGridgrid").jqGrid('navGrid',"#curruntppeGridpager",{cloneToTop:true,position:'right',edit:false,add:false,del:true,search:false,refresh:false,pgbuttons:false},
                {},{},{mtype:'POST',reloadAfterSubmit:true,
                    serializeDelData: function (postdata) {
                        var row = jQuery('#curruntppeGridgrid').getRowData(postdata.id);
                        // append postdata with extra information 
                        return {id: postdata.id, oper: postdata.oper,gridId:'current'};
                    }},{});

        //top toolbar
        jQuery("#curruntppeGridgrid").jqGrid('inlineNav','#curruntppeGridgrid_toppager',
                {position:'right',editParams : {aftersavefunc:function()
                    {
                        $("#curruntppeGridgrid").jqGrid().trigger("reloadGrid");
                        $('#del_curruntppeGridgrid_top').removeClass('ui-state-disabled');//this is added to enable delete button after saveing record
                    },oneditfunc: function() {
                        $('#del_curruntppeGridgrid_top').addClass('ui-state-disabled');//this is added to disable delete button while editing record
                    },
                    afterrestorefunc :function() {
                        $('#del_curruntppeGridgrid_top').removeClass('ui-state-disabled');//this is added to enable delete button while cancelling record
                    }
                    ,extraparam:{
                        currentApplicationId: function() { return $("#selectApplication option:selected").val(); }
                    }
                  },

                  "restoreAfterSelect":false
                });

});     

function categorycheck(value,colname)
{
    if(parseInt(count)>=1){
        //return [false,':You can add only one (Inner/Outer) product per Category'];
        return [false,':'+youCanAddOnlyOneInnerOuterProductPerCategory];
    }else{
        return [true,""];
    }


}

function Unformat_Select(cellvalue, options, cellobject)
{
    var unformatValue = '';

    $.each(options.colModel.editoptions.value, function (k, value)
            {
        if (cellvalue == value)
        {
            unformatValue = k;
        }
            });

    return unformatValue;

}

</script>
<div id="curruntppeGridContainer" class="pad7 ansellGridContainer">
<table id="curruntppeGridgrid" class="ansellGrid"></table>
<div id="curruntppeGridpager" class="scroll" style="text-align:center;"></div>
</div>
<div id="curruntppeGriddialogSelectRow" title="Warning" style="display:none">
<p>
Please select row
</p>
</div>
4

0 回答 0