This ended up being the overall solution:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
<br /> $(document).ready(function() {<br /> var noteIcon = '<div title="Job Details" style="float:left;margin-left:5px" class="ui-pg-div ui-inline-edit"><span class="ui-icon ui-icon-note"></span></div>';<br /> <br /><br /> getColumnIndexByName = function(grid,columnName) {<br /> var cm = grid.jqGrid('getGridParam','colModel');<br /> for (var i=0,l=cm.length; i<l; i++) {<br /> if (cm<i>.name===columnName) {<br /> return i; // return the index<br /> }<br /> }<br /> return -1;<br /> };<br /> <br /><br /> DoDeliveryHolds = function(grid) {<br /> var aryIDS = $(grid).jqGrid('getDataIDs');<br /> <br /><br /> if(aryIDS.length > 0) {<br /> // Add Ajax call to do toggle in database<br /> alert(aryIDS.length);<br /> }<br /> };<br /> <br /><br /> // Here we set the altRows option globallly<br /> jQuery.extend(jQuery.jgrid.defaults, {<br /> altRows:true,<br /> altclass:'myAltRowClass',<br /> datatype: "json",<br /> jsonReader: {<br /> root: "ROWS",<br /> page: "PAGE",<br /> total: "TOTAL",<br /> records: "RECORDS",<br /> cell: "",<br /> id: "0"<br /> },<br /> emptyrecords: "No jobs to display.",<br /> rowList: [25,50,100],<br /> viewrecords: true,<br /> height: "auto",<br /> loadonce: true,<br /> footerrow: true,<br /> loadComplete: function (data) {<br /> var $self = $(this), i = getColumnIndexByName($self, 'action');<br /> <br /><br /> // nth-child need 1-based index so we use (i+1) below<br /> $("tbody > tr.jqgrow > td:nth-child("+(i+1)+") > div:nth-child(1)",$self[0]).click(function(e) {<br /> var tr=$(e.target,$self[0].rows).closest("tr.jqgrow");<br /> <br /><br /> e.preventDefault();<br /> window.location.href = 'CenterView.cfm?table=ORDER_JOBS&ID=' + tr[0].id + '&backurl=%3DJobsInbox%2Ecfm%3FPICK%5FDMS%5FCENTERID%3D15';<br /> });<br /> <br /> },<br /> colNames: [ "ID", "Delivery Type", "Service Type", "Pre-Commit", "Survey Name", "Client", "Order ID", "Job Number", "Client Reference","Internal Reference", "Type", "Product Name", "Submitted For", "Sales Coordinator", "Order Date", "Requested Date", "Standard Date", "Inbox Date", "Delivery Hold", "Pre-Commit Hold", "Analyst", " ", "Actions" ],<br /> colModel: [<br /> { name: "id", index: "id", hidden: true, key: true },<br /> { name: "delivery_type", index: "delivery_type", width: 70, formatter:'select', stype:'select', edittype:'select', editoptions: { value: ":All;External Delivery:External Delivery;Internal Data Access:Internal Data Access;Internal Delivery:Internal Delivery" } },<br /> { name: "service_type", index: "service_type", width: 65, searchoptions:{sopt:['cn','eq','bw','bn','nc','ew','en']} },<br /> { name: "isprecommit", index: "isprecommit", width: 50, align: "center", formatter:'select', stype:'select', edittype:'select', editoptions: { value: ":All;false:No;true:Yes" } },<br /> { name: "survey_name", index: "survey_name", searchoptions:{sopt:['cn','eq','bw','bn','nc','ew','en']}, formatter:'showlink', formatoptions:{baseLinkUrl:'LinkStation.cfm', addParam: '&Type=JobsInboxSurvey&PICK_DMS_CENTERID=15'} },<br /> { name: "corpname", index: "corpname", searchoptions:{sopt:['cn','eq','bw','bn','nc','ew','en']}, formatter:'showlink', formatoptions:{baseLinkUrl:'LinkStation.cfm', addParam: '&Type=JobsInboxClient&PICK_DMS_CENTERID=15'} },<br /> { name: "orderid", index: "orderid", width: 40, formatter:'showlink', formatoptions:{baseLinkUrl:'LinkStation.cfm', addParam: '&Type=JobsInboxOrder&PICK_DMS_CENTERID=15'}, search:false },<br /> { name: "jobsnumber", index: "jobsnumber", width: 60, searchoptions:{sopt:['cn','eq','bw','bn','nc','ew','en']}, formatter:'showlink', formatoptions:{baseLinkUrl:'CenterView.cfm', addParam: '&table=ORDER_JOBS&backurl=%3DJobsInbox%2Ecfm%3FPICK%5FDMS%5FCENTERID%3D15'} },<br /> { name: "clientref", index: "clientref", width: 60, searchoptions:{sopt:['cn','eq','bw','bn','nc','ew','en']} },<br /> { name: "internal_reference", index: "internal_reference", width: 33, formatter:'select', stype:'select', edittype:'select', editoptions: { value: ":;EOM:EOM;NO GO:NO GO" } },<br /> { name: "survey_type", index: "survey_type", width: 35, align: "center", formatter:'select', stype:'select', edittype:'select', editoptions: { value: ":All;2D:2D;3D:3D" } },<br /> { name: "product_name", index: "product_name", searchoptions:{sopt:['cn','eq','bw','bn','nc','ew','en']} },<br /> { name: "submitted_for", index: "submitted_for", width: 70, searchoptions:{sopt:['cn','eq','bw','bn','nc','ew','en']} },<br /> { name: "sales_coordinator", index: "sales_coordinator", width: 70, searchoptions:{sopt:['cn','eq','bw','bn','nc','ew','en']} },<br /> { name: "order_date", index: "order_date", width: 50, align: "center", search:false, datefmt: 'mm/dd/yy' },<br /> { name: "requested_date", index: "requested_date", width: 50, align: "center", search:false, datefmt: 'mm/dd/yy' },<br /> { name: "dt_standard", index: "dt_standard", width: 50, align: "center", search:false, datefmt: 'mm/dd/yy' },<br /> { name: "inbox_date", index: "inbox_date", width: 50, align: "center", search:false, datefmt: 'mm/dd/yy' },<br /> { name: "isdeliveryhold", index: "isdeliveryhold", sortable: true, search: true, width: 50, align: "center", formatter:'select', stype:'select', editable:true, edittype:'select', editoptions: { value: ":;false:No;true:Yes" } },<br /> { name: "isprecommithold", index: "isprecommithold", sortable: true, search: true, width: 50, align: "center", formatter:'select', stype:'select', editable:true, edittype:'select', editoptions: { value: ":;false:No;true:Yes" } },<br /> { name: "analyst", index: "analyst", width: 115, align: "center", sortable: true, search: true, formatter:'select', stype:'select', editable:true, edittype:'select', editoptions: { value: ":;michael-19810202:Mike Hares;sara-20061004:Sara Kathleen Lampman" } },<br /> { name: 'action', index: 'action', sortable: false, search: false, width: 25, formatter: function() { return noteIcon; } },<br /> { name: "act", index: "act", width: 55, align: "center", sortable: false, search:false, formatter: "actions",<br /> formatoptions: {<br /> keys: true, delbutton: false, afterSave: function() { $(this).jqGrid('setGridParam', {datatype:'json'}); $(this).trigger('reloadGrid', [{page:1}]); }<br /> }<br /> }<br /> ],<br /> editurl: "Components/JobsInbox.cfc?method=SetJobUpdate&UPDATEDBY=aaron-20040630",<br /> afterInsertRow:<br /> function(rowid, aData){<br /> if(aData.isdeliveryhold) {<br /> $(this).setCell(rowid,"isdeliveryhold","",{"background":"#FF6A6A"});<br /> }<br /> }<br /> });<br /> <br /><br /> $('#Jobs').jqGrid({<br /> url: "Components/JobsInbox.cfc?method=GetJobGrid&PICK_DMS_CENTERID=15&CFDateFormat=MM/DD/YY",<br /> caption: "Jobs Inbox",<br /> pager: $('#JobsPager')<br /> });<br /> $('#Jobs').jqGrid('filterToolbar', { searchOperators: false, ignoreCase: true });<br /> $('#Jobs').jqGrid('navGrid', '#JobsPager', { add: false, edit: false, del: false, refresh: false });<br /> $('#Jobs').jqGrid('navButtonAdd', '#JobsPager', { caption: "", buttonicon: "ui-icon-refresh", title: $.jgrid.nav.refreshtitle, onClickButton: function() { $(this).jqGrid('setGridParam', {datatype:'json'}); $(this).trigger('reloadGrid', [{page:1}]); } });<br /> $('#Jobs').jqGrid('navButtonAdd', '#JobsPager', { caption: "Toggle Delivery Holds", buttonicon: "ui-icon-pencil", onClickButton: function() { var str = confirm("Toggle the Delivery Hold for all displayed Jobs?"); if(str) { DoDeliveryHolds($(this)); } } });<br /> <br /><br /> var orgRowActions = $.fn.fmatter.rowactions;<br /> $.fn.fmatter.rowactions = function (act) {<br /> var $tr = $(this).closest("tr.jqgrow"),<br /> rid = $tr.attr("id"),<br /> $grid = $(this).closest("table.ui-jqgrid-btable"),<br /> rowData = $grid.jqGrid("getLocalRow", rid),<br /> isNonEditable = false,<br /> result;<br /> <br /><br /> // editable property of any column<br /> if (act === "edit" && rowData.isprecommit == false) {<br /> $grid.jqGrid("setColProp", "isprecommithold", {editable: false});<br /> isNonEditable = true;<br /> }<br /> result = orgRowActions.call(this, act);<br /> if (isNonEditable) {<br /> // reset the setting to original state<br /> $grid.jqGrid("setColProp", "isprecommithold", {editable: true});<br /> }<br /> return result;<br /> }<br /> <br /><br /> });<br /> <br /> <br /><br /> <style type="<a class="attribute-value" target="_blank" rel="nofollow">text/css</a>"><br /> .myAltRowClass { background-color: #ECF6FC; background-image: none; }<br /> <br /><br /> /* Wrap in header cell */<br /> .ui-jqgrid .ui-jqgrid-htable th div {<br /> height:auto;<br /> overflow:hidden;<br /> padding-right:4px;<br /> padding-top:2px;<br /> position:relative;<br /> vertical-align:text-top;<br /> white-space:normal !important;<br /> }<br /> <br /><br /> /* Wrap in table cell */<br /> .ui-jqgrid tr.jqgrow td {<br /> white-space: normal !important;<br /> height:auto;<br /> vertical-align:text-top;<br /> padding-top:2px;<br /> }<br /> <br /><br /> span.cellWithoutBackground {<br /> display:block;<br /> background-image:none;<br /> margin-right:-2px;<br /> margin-left:-2px;<br /> height:14px;<br /> padding:4px;<br /> }<br /> </i> |
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top