Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DataHandler.getAssignedTasks(Id, Role, Type, city, Flag, Loc, Month, cat, Act,
- { callback : function(data){
- /**
- * Setting result values into local variable
- */
- resultSet = data;
- var Grid = $("#Grid");
- /**
- * Deciding the sorting format according to the Date format.
- */
- var sortingType = "";
- if("yy/mm/dd" == gUserDateFormat)
- {
- sortingType = 'text';
- }
- else if("dd/mm/yy" == gUserDateFormat)
- {
- sortingType = 'date';
- }
- /**
- * Configure the grid for the required fields with values and load the data in
- * the DIV 'taskGrid'
- */
- Grid.jqGrid({
- datatype : "local",
- data : resultSet,
- height : (gridRows * 7) + 5,
- width : pageInnerWidth - (pageInnerWidth * 0.1225),
- sortable : false,
- ignoreCase : true,
- sortorder : "desc",
- colNames : ['Title', 'Location','Act', 'mat', 'Date', 'Status', 'Action', 'Aging', 'Imp', 'Mon', 'Rev', 'Type', 'city'],
- colModel : [{
- name : 'title',
- index : 'title',
- formatter : function(cellValue, rowObject) {
- return '<a href="taskDetails?taskId=' + rowObject.rowId + '" target="_blank">' + cellValue + '</a>';
- },
- width : '160',
- align : 'left',
- sorttype : 'text'
- },{
- name : 'cLocation',
- index : 'cLocation',
- width : '275',
- align : 'left',
- sorttype : 'text',
- hidden : hideLocationData
- },{
- name : 'act',
- index : 'act',
- width : '160',
- align : 'left',
- sorttype : 'text'
- }, {
- name : 'mat',
- index : 'mat',
- width : '160',
- align : 'left',
- sorttype : 'text'
- },{
- name : 'date',
- index : 'date',
- width : '120',
- align : 'left',
- sorttype : sortingType,
- datefmt: 'd/m/Y',
- sortable: true,
- formatoptions: {srcformat: 'd/m/Y', newformat:'d/m/Y'}
- }, {
- name : 'status',
- index : 'status',
- width : '110',
- align : 'left',
- sorttype : 'text'
- }, {
- name : 'actionLink',
- index : 'actionLink',
- formatter : function(cellValue, rowObject) {
- return '<a href="companyDetails?taskId=' + rowObject.rowId + '" target="_blank">' + cellValue + '</a>';
- },
- width : '80',
- align : 'left',
- sortable : false,
- searchable : false,
- hidden : hideActionLink
- }, {
- name : 'aging',
- index : 'aging',
- width : '70',
- align : 'left',
- sorttype : 'numeric'
- }, {
- name : 'imp',
- index : 'imp',
- width : '120',
- align : 'left',
- sorttype : 'text',
- hidden : hideimpData
- }, {
- name : 'mon',
- index : 'mon',
- width : '120',
- align : 'left',
- sorttype : 'text',
- hidden : hideMonData
- }, {
- name : 'revName',
- index : 'revName',
- width : '120',
- align : 'center',
- sorttype : 'text',
- hidden : hideRevData
- }, {
- name : 'typeName',
- index : 'typeName',
- width : '5',
- align : 'center',
- sorttype : 'text',
- hidden : true,
- searchoptions : { searchhidden : true }
- }, {
- name : 'cityName',
- index : 'cityName',
- width : '5',
- align : 'center',
- sorttype : 'text',
- hidden : true,
- searchoptions : { searchhidden : true }
- }
- ],
- rowList : [ 15, 30, 50, 75, 100 ],
- pager : '#taskPager',
- rowNum : gridRows,
- altRows : true,
- altclass : "myclass",
- viewrecords : true
- });
- if (!searchEnabledOnTaskGrid)
- {
- /**
- * Configure the grid 'taskGrid' to enable search on fields
- */
- taskGrid.jqGrid('filterToolbar',{
- searchOnEnter : false,
- defaultSearch : "cn",
- beforeSearch : function(){
- if (specialCharactersCheck($("#gs_title").val())
- || specialCharactersCheck($("#gs_cLocation").val())
- || specialCharactersCheck($("#gs_act").val())
- || specialCharactersCheck($("#gs_mat").val())
- || specialCharactersCheck($("#gs_date").val())
- || specialCharactersCheck($("#gs_statusText").val())
- || specialCharactersCheck($("#gs_actionLink").val())
- || specialCharactersCheck($("#gs_aging").val())
- || specialCharactersCheck($("#gs_impName").val())
- || specialCharactersCheck($("#gs_monName").val())
- || specialCharactersCheck($("#gs_revName").val())
- || specialCharactersCheck($("#gs_typeName").val())
- || specialCharactersCheck($("#gs_cityName").val()))
- {
- return true;
- }
- else
- {
- valtypeName = $("#typeName option:selected").text();
- if (valTaskType == "Show All")
- {
- valtypeName = "";
- }
- valcity = $("#city option:selected").text();
- if (valcity == "Show All")
- {
- valcity = "";
- }
- var myGrid = $("#taskGrid");
- var myFilter = {groupOp: "AND", mats: []};
- var postData = myGrid.jqGrid('getGridParam','postData');
- var searchData = jQuery.parseJSON(postData.filters);
- for (var iMat = 0; iMat < searchData.rules.length; iMat ++)
- {
- myFilter.mats.push({ field: searchData.mats[iMat ].field, op: "cn", data: searchData.mats[iMat ].data });
- }
- if (valtypeName .length !== 0)
- {
- myFilter.mats.push({ field: "typeName", op: "cn", data: valtypeName });
- }
- if (valcity.length !== 0)
- {
- myFilter.mats.push({ field: "cityName", op: "cn", data: valcity });
- }
- myGrid[0].p.search = true;
- $.extend(myGrid[0].p.postData, { filters: JSON.stringify(myFilter) });
- myGrid.trigger("reloadGrid", [{ page: 1, current: true}]);
- return true;
- }
- }
- });
- searchEnabledOnTaskGrid = true;
- }
- },
- errorHandler : function(){
- },
- async : false
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement