I have two tables that one contains data from my local DB and when I select rows of the table and click either approval or settlement, its data get copied to my second empty table.
what I want to do is detect if selected rows already exist in my second table and if it existed, even if a user click either approval or settlement button, those rows do not get copied to second table.
I was looking for certain function for jqGrid but it looks like there is no such option.
Then I was trying to use getCol and compare employeeId of selected rows of first table and all employeeId of second table, but I get no value it when I tried
var rowDataTwo = $("#reportingList").jqGrid('getCol', columnName);
console.log(rowDataTwo);
May I ask you any good suggestion for this type of situation please?
Following is my code:
var common = {
        basUrl : function (){
            var l = window.location;
            var url =  "/" + l.pathname.split('/')[1] + "/";
            return url;
        },
        init : function(){
            common.validator();
            common.initDialog();
            common.extendJqgrid();
            common.bindEvent();
            common.datePicker();
            common.initButton();
            common.searchGrid();
            common.initGrid();
        },
        initGrid : function() {
            $("#employeeList").jqGrid(
                    {
                        url: "<c:url value='/app/getGrid'/>",
                        colNames : ['id', 'Department', 'Position', 'Employee'],
                        colModel : [
                                 {
                                    name : 'employeeId',
                                    index : 'employeeId',
                                    hidden : true,
                                    key : true
                                 },
                                 {
                                    name : 'department',
                                    index : 'department',
                                    width : 280,
                                    align : "center",
                                 },
                                 {
                                    name : 'position',
                                    index : 'position',
                                    width : 280,
                                    align : "center",
                                 },
                                 {
                                    name : 'employeeName',
                                    index : 'employeeName',
                                    width : 280,
                                    align : "center",
                                 }, 
                         ],
                         idPrefix : "g1_",
                         rowNum : 10,
                         multiselect : true,
                         multiboxonly: true,
                         pager : '#pager3',
                         viewrecords : true,
                         sortname : 'department',
                         sortorder : "asc",
                         search : false,
                         onSelectRow : function(id, status, e){
                             var selectRowId = $("#employeeList").jqGrid('getGridParam', 'selrow');
                             if (selectRowId != null) {
                                $("#btnApprovalCon, #btnSettlementCon, #btnEnforcementCon, #btnReferenceCon").button("option", "disabled", false);
                             } else {
                                $("#btnApprovalCon, #btnSettlementCon, #btnEnforcementCon, #btnReferenceCon").button("option", "disabled", true);
                                var rowData = null;
                             }
                         },
                         onSelectAll : function(rowId, status) {
                            if (status){
                                $("#btnApprovalCon, #btnSettlementCon, #btnEnforcementCon, #btnReferenceCon").button("option", "disabled", false);
                             } else {
                                $("#btnApprovalCon, #btnSettlementCon, #btnEnforcementCon, #btnReferenceCon").button("option", "disabled", true);
                             }
                         },
                         gridComplete : function(){
                             $("#btnApprovalCon").on('click', function(employeeId) {
                                    var rowDataTwo = $("#reportingList").jqGrid('getCol', employeeId);
                                    console.log(rowDataTwo);
                                    var list = $("#employeeList").jqGrid ('getGridParam', 'selarrrow'); //arrayList
                                    if(list != null){
                                        $.each(list, function(i,v){
                                                var rowData = $("#employeeList").jqGrid('getRowData', v);
                                                console.log(rowData);
                                                var data = {appset_employeeId: rowData.employeeId, appset_department: rowData.department, appset_position:rowData.position, appset_employeeName:rowData.employeeName, type:'Approval'}
                                                $("#reportingList").jqGrid('addRowData', rowData.id, data);
                                        });
                                    }
                                });
                             $("#btnSettlementCon").on('click', function(selrow) {
                                    var list = $("#employeeList").jqGrid ('getGridParam', 'selarrrow'); //arrayList(object)
                                    if(list != null){
                                        $.each(list, function(i,v){
                                                var rowData = $("#employeeList").jqGrid('getRowData', v);
                                                console.log(rowData);
                                                var rowCount = $("#reportingList").jqGrid('getGridParam', 'records');
                                                var rowNum = rowCount + 1;
                                                var data = {appset_employeeId: rowData.employeeId, appset_orderNumber: rowNum,  appset_department: rowData.department, appset_position:rowData.position, appset_employeeName:rowData.employeeName, type:'Settlement'}
                                                $("#reportingList").jqGrid('addRowData', rowData.id, data);
                                        });
                                    }
                                });
                         }
                    }).navGrid("#pager3", { search:false, edit:false, add:false, del:false});   
            $("#reportingList").jqGrid(
                    {
                        colNames : ['id', 'Department', 'Position', 'Employee', 'Type'],
                        colModel : [
                         {
                            name : 'appset_employeeId',
                            index : 'appset_employeeId',
                            hidden : true,
                            key : true
                         },
                         {
                            name : 'appset_department',
                            index : 'appset_department',
                            width : 210,
                            align : "center",
                         },
                         {
                            name : 'appset_position',
                            index : 'appset_position',
                            width : 210,
                            align : "center",
                         },
                         {
                            name : 'appset_employeeName',
                            index : 'appset_employeeName',
                            width : 210,
                            align : "center",
                         },
                         {
                            name : 'type',
                            index : 'type',
                            width : 210,
                            align : "center",
                         }, ],
                         idPrefix : "g2_",
                         rowNum : 10,
                         multiselect : true,
                         multiboxonly: true,
                         pager : '#pager4',
                         viewrecords : true,
                         search : false,
                         viewrecords : true,
                         reloadAfterEdit : true,
                         reloadAfterSubmit : true,
                         onSelectRow : function(id, status, e){
                             var selectRowId = $("#reportingList").jqGrid('getGridParam', 'selrow');
                             if (selectRowId != null) {
                                $("#btnAppSetDel").button("option", "disabled", false);
                             } else {
                                $("#btnAppSetDel").button("option", "disabled", true);
                                var rowData = null;
                             }
                         },
                         onSelectAll : function(rowId, status) {
                            if (status){
                                $("#btnAppSetDel").button("option", "disabled", false);
                             } else {
                                $("#btnAppSetDel").button("option", "disabled", true);
                             }
                         },
                         gridComplete : function(){
                            $("#btnAppSetDel").on('click', function(columnName) {
                                var delList = $("#reportingList").jqGrid ('getGridParam', 'selarrrow'); //arrayList(object)
                                if (delList != null) {
                                    $("#reportingList").jqGrid('delRowData', delList);
                                    var rowDataTwo = $("#reportingList").jqGrid('getCol', columnName);
                                    console.log(rowDataTwo);
                                }
                            });
                         }
                    }).navGrid("#pager4", { search:false, edit:false, add:false, del:true});
            $("#reportingList").sortableRows();
            $("#reportingList").jqGrid('gridDnD');
        },
I tried to put getCol of reportingList in #btnApprovalCon click function, but it did not work, and it is not important at the moment since I cannot even get value of employeeId in reportingList.
EDIT:
gridComplete : function(){
 $("#btnApprovalCon").on('click', function() {
    var list = $("#employeeList").jqGrid ('getGridParam', 'selarrrow'); //arrayList
    if(list != null){
        $.each(list, function(i,v){
            var rowData = $("#employeeList").jqGrid('getRowData', v);
            console.log(rowData);
            var ids = $("#employeeList").jqGrid('getDataIDs');
            console.log(ids);
            var nthIds = ids[i];
            console.log(nthIds);
            var idsTwo = $("#reportingList").jqGrid('getDataIDs');
            console.log(idsTwo);
            var data = {appset_employeeId: rowData.employeeId, appset_department: rowData.department, appset_position:rowData.position, appset_employeeName:rowData.employeeName, type:'Approval'}
            $("#reportingList").jqGrid('addRowData', rowData.id, data);
        });
    }
}

