Home › Forums › Guriddo jqGrid JS › Help › Column Reordering- alignment issue
Tagged: column reordering alignment
Hello, I’ve been searching for an answer to this and can’t find a solution. I’m working on a very complex grid. Basically, when I reorder the columns, the column headers and the actual columns becoming misaligned/mismatched. I’ve tried numerous fixes and none of them seem to work. Any ideas?
Hello,
Could you please post your code or at best send a link to the problem?
For us is very difficult to give a solution with this type of description.
Kind Regards,
Will
Guriddo Support Team
Sorry, I will post the code in a few minutes. I was doing some more testing, I completely removed all of the CSS formating and the problem remains. Be back in a few moments.
This code has been trimmed down significantly
|
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 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
mainApp.directive('ngJqGrid', function () { //var errorCountValue = 0; //var warningCountValue = 0; var errorRows = []; var currentCensusSeqNum; var genderOptions = {'': '-SELECT-', 'F': 'Female', 'M': 'Male'}; var paymentModeOptions = {'': '-SELECT-', 'S': 'Semi-Annual', 'A': 'Annual'}; var occupationSpecialityOptions = {'': '-SELECT-', '-1': 'Not Applicable', '0': 'Unknown'}; var stateCodeOptions = {'': '-SELECT-', 'AL': 'Alabama', 'AK': 'Alaska'}; var censusClassIdOptions = {'': '-SELECT-', '-1': 'Not Eligible', '0': 'Decline'}; var dependentTypeOptions = {'': '-SELECT-', '0': 'None', '5': 'Decline'}; //Select options Sorting will not work with javascript object.Using this String for ordering. var tierRateOptionsStr = ":-SELECT-;0:Composite;4:EE"; return { restrict: 'E, A, C', scope: { optionId: "&optionIdAttribute", errorCountValue: "=errorValueAttribute", warningCountValue: "=warningValueAttribute", errorRows: "=errorRowsAttribute", config: '=', data: '=', btnStatus: '=', userCanEdit: '=' // requiredColumns: requiredColumnMap }, link: function (scope, element, attrs) { var lastsel3; // JQGrid based table $("#list2").jqGrid({ data: {}, datatype: "local", // Data Type height: 300, width: 1300, // make the table width 100% shrinkToFit: true, // make the table width 100% // Col Names and Model should be separated should be a service or json file colNames: [ '', 'Sequence', 'Plan Id', '<input name="jqcolHeader" type="checkbox" value="birthDate" /> DOB ', '<input name="jqcolHeader" type="checkbox" value="age" /> Age ', '<input name="jqcolHeader" type="checkbox" value="stateCode" /> State' ], colModel: [ { name: 'isChecked', index: 'isChecked', width: 60, editable: scope.userCanEdit, edittype: 'checkbox', editoptions: {value: "True:False"}, formatter: "checkbox", formatoptions: {disabled: false} }, { name: 'plnGrpId', index: 'plnGrpId', jsonmap: 'plnGrpId', hidden: true, editoptions: {class: 'form-control'} }, { name: 'birthDate', index: 'birthDate', jsonmap: 'birthDate', hidden: true, editable: scope.userCanEdit, formatter: dobFormatter, cellattr: function (rowId, tv, rawObject, cm, rdata) { if (cm.isRequired || $.trim(rdata.birthDate).length > 0) { return validateCells(rdata.birthDate, 'birthDate', 'init', 'good'); } else { return ""; } } }, { name: 'age', index: 'age', width: 110, sorttype: 'int', formatter: ageFormatter, hidden: true, editable: scope.userCanEdit, cellattr: function (rowId, tv, rawObject, cm, rdata) { // Get DOB, YOB and Age validated if (cm.isRequired || $.trim(rdata.age).length > 0) { return validateCells(rdata.age, 'age', 'init', 'good'); } else { return ""; } } }, { name: 'stateCode', index: 'stateCode', jsonmap: 'stateCode', width: 150, hidden: true, editable: scope.userCanEdit, edittype: "select", formatter: stateCodeFormatter, editoptions: { defaultValue: '', class: 'form-control', value: stateCodeOptions, dataEvents: [{ type: 'focus', fn: function (e) { setState(e, 'select-box'); } }, { type: 'change', fn: function (e) { setState(e, 'select-box'); } }, { type: 'keydown', fn: function (e) { setState(e, 'select-box'); } }] }, cellattr: function (rowId, tv, rawObject, cm, rdata) { if (cm.isRequired || $.trim(rdata.stateCode).length > 0) { return validateCells(rdata.stateCode, 'select-box', 'init', 'good', stateCodeOptions); } else { return ""; } } } ], jsonReader: { root: "rows", page: "page", total: "total", records: "records", repeatitems: false, id: "0" }, autowidth: false, editurl: 'url', fixed: false, //scroll: 1, loadonce: false, mtype: "GET", rownumbers: true, rownumWidth: 40, altclass: 'even', altRows: true, gridview: true, pager: '#pager2', sortname: 'item_id', viewrecords: true, sortorder: "asc", sortable: true, caption: "Census Data", cellEdit: true, cellsubmit: 'clientArray', ordering: true, hidegrid: false, hiddengrid: false, cellLayout: 15, afterSaveCell: function (rowid, cellname, value, iRow, iCol) { scope.$apply(function () { if (cellname == 'age') { value = $.trim(value); // trim value var dateValue = new Date($.trim($(this).getCell(rowid, 'birthDate'))); // Get date value var currentDate = new Date(); // Do the checks - null , empty, non digit and non date if (!isNaN(value) && value !== "") { // Do checks on the date value and subtract age from year if (dateValue !== "" && !isNaN(dateValue.valueOf())) { dateValue.setFullYear(currentDate.getFullYear() - value); } else { dateValue.setFullYear(currentDate.getFullYear() - value); dateValue.setDate(1); dateValue.setMonth(0); } } // set the value $(this).setCell(rowid, 'birthDate', dateValue.getDate() + "/" + (dateValue.getMonth() + 1) + "/" + dateValue.getFullYear()); } // Enable the Save Button if its disabled scope.btnStatus.isSubmitDisabled = false; // Enable the Revert Button if its disabled scope.btnStatus.isRevertDisabled = false; }); }, beforeSelectRow: function (rowid, e) { scope.$apply(function () { // arrays to maintain selected rows var $target = $(e.target); var rowData = $('#list2').getRowData(rowid); var seqNum = rowData.mbrCensusSeqNum + ""; if ($target.is(":checkbox")) { if ($target.is(":checked")) { scope.$parent.checkedRows.push(seqNum); } else if (scope.$parent.checkedRows.indexOf(seqNum) >= 0) { scope.$parent.checkedRows.splice(scope.$parent.checkedRows.indexOf(seqNum), 1); } } // Enable the duplicate and delete selected button if any row is selected if (scope.$parent.checkedRows.length > 0) { scope.btnStatus.isDuplicateSelectedDisabled = false; scope.btnStatus.isDeleteSelectedDisabled = false; } else { scope.btnStatus.isDuplicateSelectedDisabled = true; scope.btnStatus.isDeleteSelectedDisabled = true; } }); return true; }, afterEditCell: function (id, name, val, iRow, iCol) { //Modify event handler to save on change. $("#" + iRow + "_" + name, "#list2").bind('change', function () { $('#list2').saveCell(iRow, iCol); }); scope.$apply(function () { // Enable the Save Button if its disabled scope.btnStatus.isSubmitDisabled = false; // Enable the Revert Button if its disabled scope.btnStatus.isRevertDisabled = false; }); }, beforeRequest: function () { scope.errorCountValue = 0; scope.warningCountValue = 0; errorRows = []; scope.$parent.checkedRows = []; }, gridComplete: function () { toggleViewErrorsOnlyLink(scope.errorCountValue); } }); $("#list2").jqGrid('navGrid', '#pager2', {edit: false, add: true, del: true}); } } } |
I’m trying to upload some images but I can’t figure out how to.
Hello,
Sorry, but we van not reproduce the problem.
Could you please send us a link to the problem or at last very simple example.
Please note the version used – i.e jQuery version, jQuery UI version and jqGrid version.
Maybe you use some versions without to update the CSS files.
Kind Regards,
Will
Guriddo Support Team
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top