카테고리 없음

jGrid 컨트롤러로 보내기

jeanbro 2017. 7. 20. 17:30





1. editable: true :


- 보낼 파라미터에 추가 


ex) {name: 'nCarNo', index: 'nCarNo', width: 80, sortable: false, editable: true},



2. $('#list').editRow('"+options.rowId+"'); $('#list').saveRow('"+options.rowId+"');

 

- $('#ID값').editRow(행번호) , $('#ID값').saveRow(행번호) 로 보내야 함


ex)  return "<input class='confirm-button'  type='button' value='확인' onclick=\"$('#list').editRow('"+options.rowId+"');$('#list').saveRow('"+options.rowId+"'); /*         $('#list').delRowData('"+options.rowId+"'); */\" \>";










전체 소스


  

var lastsel;

        $(function() {

           $('#list').jqGrid({

               autoencode: false,

               url: 'insuVinList.do',

               postData: getGridFilter(),

               datatype: 'json',

               height: 'auto',

               colNames: [

                   '증권번호', '보험시작일',

                   '차명', '차량번호', '차대번호',

                   '블랙박스', '가격(공급가)', '시리얼번호',

                   '등록코드', '차량번호', '차대번호', '시퀀스', '블랙박스', '가격(공급가)', '시리얼번호',

                   '수정',

               ],

               colModel: [

                   {name: 'value15', index: 'value15', width: 120, sortable: false},

                   {name: 'insStartDt', index: 'insStartDt', width: 120, sortable: false},


                   {name: 'value03', index: 'value03', width: 240, sortable: false},

                   {name: 'nCarNo', index: 'nCarNo', width: 80, sortable: false, editable: true},

                   {name: 'nCarNum', index: 'nCarNum', width: 170, sortable: false, editable: true},


                   {name: 'nBlackboxNm', index: 'nBlackboxNm', width: 150, sortable: false, editable: true},

                   {name: 'nBlackboxAmt', index: 'nBlackboxAmt', width: 100, sortable: false, editable: true, align: 'right', formatter: 'integer'},

                   {name: 'nBlackboxNo', index: 'nBlackboxNo', width: 130, sortable: false, editable: true},


                   {name: 'regCode', index: 'regCode', hidden: false, editable: true},

                   {name: 'seq', index: 'seq', hidden: false, editable: true},

                   {name: 'oCarNo', index: 'oCarNo', width: 80, hidden: false, editable: true},

                   {name: 'oCarNum', index: 'oCarNum', width: 170, hidden: true, editable: true},

                   {name: 'oBlackboxNm', index: 'oBlackboxNm', width: 100, hidden: true, editable: true},

                   {name: 'oBlackboxAmt', index: 'oBlackboxAmt', width: 100, hidden: true, editable: true},

                   {name: 'oBlackboxNo', index: 'oBlackboxNo', width: 100, hidden: true, editable: true},


                   {name: 'act', index: 'act', width: 50, align: 'center', sortable: false, formatter:function (cellvalue, options, rowObject) {

                       return "<input class='confirm-button'  type='button' value='확인' onclick=\"$('#list').editRow('"+options.rowId+"');$('#list').saveRow('"+options.rowId+"'); /* $('#list').delRowData('"+options.rowId+"'); */\" \>";

                   }},

               ],

               caption: "보험 차대번호 확정",

               formatter: {

                   integer: {

                       thousandsSeparator: ',', deaultValue: '0'

                   }

               },

               rownumbers: true,

               rowNum: 20,

               rowList:[20,30,40],

               pager: '#pager',

               sortname: 'value15',

               viewrecords: true,

               jsonReader : {

                   repeatitems: false,

               },

               loadComplete: function(data) {           // 로드 완료후

                   var ids = $('#list').getDataIDs();

                   $.each(ids, function(idx, rowId) {

                       var row = $('#list').getRowData(rowId);

                       if (row.oCarNo != row.nCarNo) {

                           $('#list').setCell(rowId, 'nCarNo', '', {color: "red"});

                       }

                       if (row.oCarNum != row.nCarNum) {

                           $('#list').setCell(rowId, 'nCarNum', '', {color: "red"});

                       }

                       if (row.oBlackboxNo != row.nBlackboxNo) {

                           $('#list').setCell(rowId, 'nBlackboxNo', '', {color: "red"});

                       }

                       if (row.oBlackboxNum != row.nBlackboxNum) {

                           $('#list').setCell(rowId, 'nBlackboxNum', '', {color: "red"});

                       }

                       if (row.oBlackboxAmt != row.nBlackboxAmt) {

                           $('#list').setCell(rowId, 'nBlackboxAmt', '', {color: "red"});

                       }


                   });

               },

               editurl: "insuVinList.do",               // 셀수정 url

               serializeRowData: function (data) {      // 셀수정 데이타

                   $('#list .confirm-button').prop('disabled', true);

                   return JSON.stringify(data);

               },

               reloadAfterEdit: true,

//               recordtext: "View {0} - {1} of {2}",

//               emptyrecords: "데이터가 없습니다",

//               loadtext: "조회중...",

//               pgtext: '페이지 {0} / {1}',


           });

            $('#list').jqGrid('setGroupHeaders', {

                useColSpanStyle: true,

                groupHeaders:[

                    {startColumnName: 'value15', numberOfColumns: 2, titleText: '보험정보'},

                    {startColumnName: 'value03', numberOfColumns: 3, titleText: '차량정보'},

                    {startColumnName: 'nBlackboxNm', numberOfColumns: 3, titleText: '블랙박스'},

                ]

            });


            $('#search_button').bind('click', function() {

                $('#list').jqGrid('setGridParam', {postData: null});

                $('#list').jqGrid('setGridParam', {

                    postData: getGridFilter(),

                }).trigger("reloadGrid");

            });


            $('#search_period').selectmenu({width: 80});

            $('#search_gubun').selectmenu({width: 80});

            $('#search_query_select').selectmenu({width: 110});


            // 기간검색일 때만 datepicker가 보이도록

            $('#search_period').bind('selectmenuchange', function() {

                var value = $(this).val();

                if (value == 'period') {

                    $('.search-period-date').show();

                } else {

                    $('.search-period-date').hide();

                }

            });