
$(function () {
var mydata = [
        { id: "1", invdate: "2010-05-24", name: "test", note: "note", tax: "10.00", total: "2111.00" },
        { id: "2", invdate: "2010-05-25", name: "test2", note: "note2", tax: "20.00", total: "320.00" },
        { id: "3", invdate: "2007-09-01", name: "test3", note: "note3", tax: "30.00", total: "430.00" },
        { id: "4", invdate: "2007-10-04", name: "blah", note: "stuff", tax: "10.00", total: "210.00" },

    ];
    var var2 = "##";
    //if (usermenu1.indexOf("M225") != -1) {
    var Flag = 0;               //ALL WORK ITEM VIEW RIGHT
    //}
    //else {
    //    var Flag = 4;               //NOT ALL WORK ITEM VIEW RIGHT
    //}



    var1 = "1=1";
    var2 = "##";
    debugger;
    var Type = 0;
    var UserId = 1;
    var DepartmentId = 1;
    var FromDate = '01/08/2023';
    var ToDate = '08/08/2023';
    var Variable1 = var1;
    var Variable2 = '';




grid = jQuery("#grid");

grid.jqGrid({
    url: "/Home/GetValues?Type=" + Type + "&UserId=" + UserId + "&DepartmentId=" + DepartmentId + "&FromDate='" + FromDate + "'&ToDate='" + ToDate + "'&Variable1='" + Variable1 + "'&Variable2='" + Variable2 + "'",
   datatype: 'json',
     mtype: 'Get',


  //  data: mydata,
   // datatype: "local",
    height: 150,
    rowNum: 10,
    rowList: [10, 20, 30],
    colNames: ['Sl', 'Dept', 'Salesman'], 
    colModel: [
      {
          name: 'slno',
          index: 'slno',
          sorttype: "int",
          search: true
      },
      {

          name: 'Dept',
          index:'Dept',

          search: true
      },
      {
          name: 'AssignedByUser',
          index:'AssignedByUser',
          search: true

      }
     
   
  //  colNames: ['Inv No', 'Date', 'Client', 'Amount', 'Tax', 'Total', 'Notes'],
    //colModel: [
    //       { name: 'id', index: 'id', width: 60, sorttype: "int", search: true },
    //       { name: 'invdate', index: 'invdate', width: 90, sorttype: "date", formatter: "date" },
    //       { name: 'name', index: 'name', width: 100 },
    //       { name: 'amount', index: 'amount', width: 80, align: "right", sorttype: "float", formatter: "number" },
    //       {
    //           name: 'tax', index: 'tax', width: 80, align: "right", sorttype: "float",
    //           searchoptions: { sopt: ['gt'] }
    //       },
    //       { name: 'total', index: 'total', width: 80, align: "right", sorttype: "float" },
    //       { name: 'note', index: 'note', width: 150, sortable: false }
    ],
    pager: "#pager",
    viewrecords: true,
    autowidth: true,
    height: 'auto',
    caption: "Test Grid",
    loadonce: true
});




jQuery("#grid").jqGrid('filterToolbar', { stringResult: true, searchOnEnter: false, defaultSearch: "cn" });


  });





//$(function () {
//    debugger;
//    $("#grid").jqGrid
//    ({
//        url: "/Home/TestGetValues",
//        datatype: 'json',
//        mtype: 'Get',
//        //table header name   
//        colNames: ['SalesMainId', 'CustAddress'],
//        //colModel takes the data from controller and binds to grid    
 
//        colModel: [
//          {
//              key: true,
//              name: 'SalesMainId',
//              index: 'SalesMainId',
//              editable: true
//          }, {
//              key: false,
//              name: 'CustAddress',
//              index: 'CustAddress',
//              editable: true
//          }],

//        pager: jQuery('#pager'),
//        rowNum: 10,
//        rowList: [10, 20, 30, 40],
//        height: '100%',
//        viewrecords: true,
//        caption: 'Jq grid sample Application',
//        emptyrecords: 'No records to display',
//        jsonReader:
//        {
//            root: "rows",
//            page: "page",
//            total: "total",
//            records: "records",
//            repeatitems: false,
//            Id: "0"
//        },
//        autowidth: true,
//        multiselect: false
//        //pager-you have to choose here what icons should appear at the bottom  
//        //like edit,create,delete icons  
//    }).navGrid('#pager',
//    {
//        edit: true,
//        add: true,
//        del: true,
//        search: false,
//        refresh: true
//    }, {
//        // edit options  
//        zIndex: 100,
//        url: '/Jqgrid/Edit',
//        closeOnEscape: true,
//        closeAfterEdit: true,
//        recreateForm: true,
//        afterComplete: function (response) {
//            if (response.responseText) {
//                alert(response.responseText);
//            }
//        }
//    }, {
//        // add options  
//        zIndex: 100,
//        url: "/Jqgrid/Create",
//        closeOnEscape: true,
//        closeAfterAdd: true,
//        afterComplete: function (response) {
//            if (response.responseText) {
//                alert(response.responseText);
//            }
//        }
//    }, {
//        // delete options  
//        zIndex: 100,
//        url: "/Jqgrid/Delete",
//        closeOnEscape: true,
//        closeAfterDelete: true,
//        recreateForm: true,
//        msg: "Are you sure you want to delete this task?",
//        afterComplete: function (response) {
//            if (response.responseText) {
//                alert(response.responseText);
//            }
//        }
//    });

//   // $('#grid').jqGrid('filterToolbar', { stringResult: true, searchOnEnter: false, defaultSearch: "cn", searchOperators: true, autosearch: true });

//    jQuery("#grid").jqGrid('filterToolbar', { stringResult: true, searchOnEnter: false, defaultSearch: "cn" });


function getordertype(cellValue, opts, rowObject) {

    if (cellValue == null || cellValue == 1451520000) {
        return '';
    } else {


        var data = cellValue.split('#')[1];

        return data;
    }
}
function getlocation(cellValue, opts, rowObject) {

    if (cellValue == null || cellValue == 1451520000) {
        return '';
    } else {

        var data = cellValue.split('#')[2];

        return data;
    }
}

