solution For:
- Freeze jqGrid columns
- Unload/Unbind grid.
- Search by Textbox for all rows and columns
JQ grid version: v5.3.2
HTML
<div class="pull-right" style="font-weight: normal;font-style: normal;">
<input type="text" ng-model="srchCnsldRcpt" placeholder="Search Here" ng-keyup="bindJqGrid('cnsld',
Rcpt)" />
</div>
</td>
<%--jq
grid--%>
<table id="gvCnsldRcpt"></table>
JavaScript
$scope.bindJqGrid
= function (key, p1) {
try {
if (key == 'cnsld') {
$.jgrid.gridUnload("#gvCnsldRcpt");
var colName = Object.keys(p1[0]);
var colMdl = [];
var p2 = [];
if (typeof
$scope.srchCnsldRcpt != 'undefined' && $scope.srchCnsldRcpt.trim() != '') {
for (var x = 0; x < p1.length; x++) {
var cnt = 0;
for (var j = 0; j < colName.length; j++) {
var cnm = p1[x][colName[j]] + "";
var fnd =
cnm.toLowerCase().search($scope.srchCnsldRcpt.toLowerCase().trim());
if (parseInt(cnt) == 0 &&
parseInt(fnd) >= 0) {
p2.push(p1[x]);
cnt = 1;
}
}
}
}
else
p2 = p1;
for (var i = 0; i
< colName.length; i++) {
var jq = {};
jq.name = colName[i];
jq.index = colName[i];
if (i == 0 || i == 1) {
jq.frozen = true;
jq.width = 100;
jq.search = true;
}
else {
jq.width = 60;
}
colMdl.push(jq);
}
$("#gvCnsldRcpt").jqGrid({
datatype: 'local',
data: p2,
gridview: true,
colNames: colName,
colModel: colMdl,
height: "120",
shrinkToFit: false,
width: 620,
loadError: function (xhr, status, error) {
alert('error');
}
});
$("#gvCnsldRcpt").jqGrid("setFrozenColumns");
}
}
catch (ex) {
alert(ex.message);
}
}