1

グリッドには、ユーザーがドロップダウンを使用して値を設定できる1つの列があります。その列で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