0

いくつかの投稿を見てきましたが、使い方がわかりませんjsonReader。編集、追加するときは、主キーを非表示にしておきたいです。パーミッションIDを作成するeditable:falseか非表示にすると、編集されません。

他の投稿へのヘルプや指示は素晴らしく、非常にありがたいです。ありがとう

これが私のコードです:

$(document).ready(function()
    {   
        $("#list").jqGrid(
        {
            url:'Users2.cfc?method=getUsers', //CFC that will return the users
            datatype: 'json', //We specify that the datatype we will be using will be JSON
            colNames:['Bill To Code','User ID', 'GL_comp_key', 'Branch ID', 'Warehouse ID', 'Final Approver',  'Active', 'Primary Approver', 'Administrative','Secondary Approver','permissionID'], //Column Names
            //The Column Model to define the data. Note you can make columns non sortable, specify width, alignment, etc.
            colModel :[
                {name:'ar_bill_key',index:'ar_bill_key', width:125, sorttype:"text",editable:true,searchoptions:{sopt:['eq','lt','le','gt','ge','bw','ew','cn']},
                    editable:true,edittype:"text",editoptions:{size:50},editrules:{required:true},formoptions:{elmprefix:"(*)"}},
                {name:'userID',index:'userID', width:125, align:"left",sorttype:"text",searchoptions:{sopt:['eq','bw','ew','cn']},
                    editable:true,edittype:"text",editoptions:{size:50},editrules:{required:true},formoptions:{elmprefix:"(*)"}},
                {name:'gl_cmp_key',index:'gl_cmp_key', width:125, align:"left",sorttype:"text",searchoptions:{sopt:['eq','bw','ew','cn']},
                    editable:true,edittype:"text",editoptions:{size:50},editrules:{required:true},formoptions:{elmprefix:"(*)"}},
                {name:'so_brnch_key',index:'so_brnch_key', width:125, align:"left",sorttype:"text",searchoptions:{sopt:['eq','bw','ew','cn']},
                    editable:true,edittype:"text",editoptions:{size:50},editrules:{required:true},formoptions:{elmprefix:"(*)"}},
                {name:'so_whs_key',index:'so_whs_key', width:125,align:"left",sorttype:"text",searchoptions:{sopt:['eq','bw','ew','cn']},
                    editable:true,edittype:"text",editoptions:{size:50},editrules:{required:true},formoptions:{elmprefix:"(*)"}},
                {name:'final_approver',index:'final_approver', width:125,align:"left",sorttype:"text",searchoptions:{sopt:['eq','bw','ew','cn']},
                    editable:true,edittype:"select",editoptions:{value:"1:Yes;0:No"},editrules:{required:true},formoptions:{elmprefix:"(*)"}},  
                {name:'active',index:'active', width:125,align:"left",sorttype:"text",searchoptions:{sopt:['eq','bw','ew','cn']},
                    editable:true,edittype:"select",editoptions:{value:"1:Yes;0:No"},editrules:{required:true},formoptions:{elmprefix:"(*)"}},
                {name:'primary_approver',index:'primary_approver', width:125,align:"left",sorttype:"text",searchoptions:{sopt:['eq','bw','ew','cn']},
                    editable:true,edittype:"select",editoptions:{value:"1:Yes;0:No"},editrules:{required:true},formoptions:{elmprefix:"(*)"}},  
                {name:'admin',index:'admin', width:125,align:"left",sorttype:"text",searchoptions:{sopt:['eq','bw','ew','cn']},
                    editable:true,edittype:"select",editoptions:{value:"1:Yes;0:No"},editrules:{required:true},formoptions:{elmprefix:"(*)"}},  
                {name:'secondary_approver',index:'secondary_approver', width:130,align:"left",sorttype:"text",searchoptions:{sopt:['eq','bw','ew','cn']},
                    editable:true,edittype:"select",editoptions:{value:"1:Yes;0:No"},editrules:{required:true},formoptions:{elmprefix:"(*)"}},
                {name:'permissionID',index:'permissionID',sorttype:"int",editable:true,searchoptions:{sopt:['eq','lt','le','gt','ge']}},
            ],//searchoptions parameter is used to limit the operators available during search
            pager: $('#pager'), //The div we have specified, tells jqGrid where to put the pager
            rowNum:20, //Number of records we want to show per page
            rowList:[20,30,40,50], //Row List, to allow user to select how many rows they want to see per page
            sortorder: "desc", //Default sort order
            sortname: "ar_bill_key", //Default sort column
            viewrecords: true, //Shows the nice message on the pager
            imgpath: '/images', //Image path for prev/next etc images
            caption: 'Permissions', //Grid Name
            recordtext: "Record {0} - {1} of {2}",//Pager information to show
            rownumbers: true,//Show row numbers
            rownumWidth: "30",//Width of the row numbers column
            sortable: true,
            height:'auto', //I like auto, so there is no blank space between. Using a fixed height can mean either a scrollbar or a blank space before the pager
            mtype:'POST',   
            toolbar:[true,"top"], //Shows the toolbar at the top. We will use it to display user feedback
            //The JSON reader. This defines what the JSON data returned from the CFC should look like
            jsonReader: {
                root: "ROWS", //our data
                page: "PAGE", //current page
                total: "TOTAL", //total pages
                records:"RECORDS", //total records
                userdata:"USERDATA", //Userdata we will pass back for feedback
                cell: "", //Not Used
                ar_bill_key: "0" //Will default to first column
                },
            editurl:"Users2.cfc?method=addeditUser" //The Add/Edit function call                
            }               
        ).navGrid('#pager',
            {
                search:true,searchtitle:"Search",//title set for hover over display
                edit:true,edittitle:"Edit User",
                add:true,addtitle:"Add User",
                del:false,deltitle:"Delete User"
            },
        // Edit Options. savekey parameter will keybind the Enter key to submit.
        {editCaption:"Edit User",edittext:"Edit",closeOnEscape:true, savekey: [true,13],errorTextFormat:commonError
            ,reloadAfterSubmit:true,bottominfo:"Fields marked with (*) are required",top:"60",left:"70",width:500}, 
        {width:500,addCaption:"Add User",edittext:"Add",closeOnEscape:true,savekey: [true,13],errorTextFormat:commonError,
            reloadAfterSubmit:true,bottominfo:"Fields marked with (*) are required",top:"60",left:"70"}, //Add Options
        {url:"Users2.cfc?method=delUser",caption:"Delete User",closeOnEscape:true,errorTextFormat:commonError,top:"60",left:"70",
            reloadAfterSubmit:true}, //Delete Options
         //Search Options. multipleSearch parameter lets it know we are going to use the new advanced search feature
        {errorTextFormat:commonError,Find:"Search",closeOnEscape:true,caption:"Search Users",multipleSearch:true,closeAfterSearch:true}
        );          

        //Function will be called when add/edit encounters an error. The returned message is what will be shown to user 
        function commonError(data)
        {           
            return "Error Occured during Operation. Please try again";
        }

    }
);
4

1 に答える 1

1

あなたの質問が正しいと理解できればpermissionID、それは編集中に送信されますが、どこかに表示する必要はありません。

どのIDにグリッドの行が必要かを指定しないという元の問題があると思います。JSON 入力には、id. cell: ""で設定を使用する場合jsonReader、次の 2 つの方法のいずれかで行の ID を指定する必要があります。

  • key: true列の定義にプロパティを含めました'permissionID'。列を編集可能にする必要がない場合 (削除できますeditable:true)。
  • ユーザーに列を表示する必要がない場合は、列を削除してプロパティに含める'permissionID'ことができます。計算が正しければ、主キーを 10 番目の位置に配置しました。この場合、値はグリッドの行 (要素)としてのみ保存されます。は常にすべての編集操作で送信されます。'permissionID'jsonReaderid: "10"permissionIDpermissionIDid<tr>id
于 2012-02-27T20:39:02.310 に答える