/**
*
*/
var currentPageNo = 0;
var recordLength = 20;
var totalRecords = 100;
var tableName = "";
var url = "";
var headerAction = 0;
var headerContent = "";
var rowAction = 0;
var genericlist;
var totalPages = 0;
var searchOperations = new Array();
var ORSearchOperations = new Array();
var searchFilterOperations = new Array();
var orderByOperant = "";
var assending = true;
var initCount = false;
var orderByCol = "";
var orderByTF = true;
var loadingDialog=true;
// ======================== for classes =======================================
function gridAction() {
this.actionName = "";
this.functionName = "";
this.imagePath = "";
this.direction ="";
this.isActive = false;
this.isHeader = false;
this.bindProperty=""; /* conditional action display */
}
function gridColumn() {
this.title = "";
this.attribute = "";
this.datatype = "";
this.width = "";
}
function dynamicGrid() {
this.gridObj = "";
this.gridTitle = "";
this.className = "";
this.formId = "";
this.currentPageNo = 0;
this.recordLength = 100;
this.totalRecords = 100;
this.totalPages = 0;
this.disableCount = false;
this.retainFilterSearch=false;
this.column = new Array();
this.actionList = new Array();
this.filterOperation = new Array();
this.interSearch = new seInput();
this.lastFilterOperation = new Array();
this.imageArray = new Array();
this.lastPageStatus=0;
this.reDraw=true;
this.isPost=false;
this.sortType=0; /* multi order by */
this.assending = true;
this.leftHeaderAction=0;
this.leftRowAction =0;
this.rightHeaderAction=0;
this.rightRowAction=0;
this.leftHeaderContent="";
this.rightHeaderContent="";
this.orderByOperant = "";
this.urlForGridData = "";
this.nextGrid = "";
this.loadingDialog=true;
this.isLoaded=false;
this.sortList = new Array();
this.defaultMultiSorting= new Array();
}
var dynamicGridObj = new dynamicGrid();
var dynamicGridObjs = new Array();
//$(function() {
// $('#processDiv').dialog({
// autoOpen : false,
// width : 250,
// height : 130,
// resizable : false,
// closeOnEscape : false,
// modal : true,
// open : function(event, ui) {
// $(".ui-dialog-titlebar").hide()
// }
// });
//});
// ===================== for grid obj to grid array ==========================
function addGrid(dynamicGridObj) {
try {
for (i = 0; i < dynamicGridObjs.length; i++) {
if (dynamicGridObjs[i].gridObj == dynamicGridObj.gridObj
&& dynamicGridObjs[i].column.length != undefined
&& dynamicGridObjs[i].column.length > 0) {
dynamicGridObjs[i].interSearch = seInputOnlyProjection(i,
dynamicGridObjs[i].interSearch);
$('#processDiv_'+i).dialog('close').remove();
return i;
}
}
dynamicGridObjs[dynamicGridObjs.length] = dynamicGridObj;
return dynamicGridObjs.length - 1;
} catch (e) {
alert("This :" + e);
}
}
// ========================= for Grid Action List
// =====================================
function createActionsList(gridNo, actionName, functionName, imagePath,isHeader,direction,bindProperty) {
try {
var t = false;
for (j = 0; j < dynamicGridObjs[gridNo].actionList.length; j++) {
if (dynamicGridObjs[gridNo].actionList[j].actionName == actionName ) {
t = true;
break;
}
}
if (t != true) {
var tempGridAction = new gridAction();
tempGridAction.actionName = actionName;
tempGridAction.functionName = functionName;
tempGridAction.imagePath = imagePath;
tempGridAction.isHeader = isHeader;
tempGridAction.direction =direction;
tempGridAction.bindProperty=bindProperty;
dynamicGridObjs[gridNo].actionList[dynamicGridObjs[gridNo].actionList.length] = tempGridAction;
}
} catch (e) {
// alert("Add Action List : "+ e);
}
}
// ============= for Grid Column List ======================
function createColumn(gridNo, title, attribute, dataType, width) {
try {
var tempColumn = new gridColumn();
tempColumn.title = title;
tempColumn.attribute = attribute;
tempColumn.datatype = dataType;
tempColumn.width = width;
dynamicGridObjs[gridNo].column[dynamicGridObjs[gridNo].column.length] = tempColumn;
} catch (e) {
// alert("Create Column :"+ e);
}
}
// ==============================================================
function createGridHeader(gridNo) {
try {
var getUrl = dynamicGridObjs[gridNo].className + "&m=" + Math.random();
$
.get(
getUrl,
function(data) {
dynamicGridObjs[gridNo].column = new Array();
dynamicGridObjs[gridNo].interSearch.projection = new Array();
var genericlist = eval('(' + data + ')');
createColumn(gridNo, "Actions", "", "", "");
for (i = 0; i < genericlist.list.length; i++) {
createColumn(gridNo,
genericlist.list[i].attributeTitle,
genericlist.list[i].attributeName,
genericlist.list[i].attributeType,
genericlist.list[i].attributeWidth);
dynamicGridObjs[gridNo].interSearch.projection[dynamicGridObjs[gridNo].interSearch.projection.length] = genericlist.list[i].attributeName;
}
dynamicGridObjs[gridNo].interSearch.projection[dynamicGridObjs[gridNo].interSearch.projection.length] = "id";
createColumn(gridNo, "Actions", "", "", "");
createAccessList(gridNo);
});
} catch (e) {
// alert(e);
}
}
function createAccessList(gridNo) {
try {
if (dynamicGridObjs[gridNo].formId != undefined
&& dynamicGridObjs[gridNo].formId != "") {
var getUrl = dynamicGridObjs[gridNo].formId + "&m=" + Math.random();
$
.get(
getUrl,
function(data) {
for (i = 0; i < dynamicGridObjs[gridNo].actionList.length; i++) {
if (data
.indexOf(dynamicGridObjs[gridNo].actionList[i].actionName) > -1) {
dynamicGridObjs[gridNo].actionList[i].isActive = true;
}
}
drawGrid(gridNo);
});
} else {
for (i = 0; i < dynamicGridObjs[gridNo].actionList.length; i++)
dynamicGridObjs[gridNo].actionList[i].isActive = true;
drawGrid(gridNo);
}
} catch (e) {
// alert("Create Access List : "+e);
}
}
// ================== for Grid creation =======================================
function createDynamicGrid(gridNo) {
try {
if(dynamicGridObjs[gridNo].retainFilterSearch==true){
dynamicGridObjs[gridNo].currentPageNo=dynamicGridObjs[gridNo].lastPageStatus;
}else{
dynamicGridObjs[gridNo].currentPageNo = 0;
}
gridIndex = gridNo;
if(document.getElementById('loadingImg')){
document.getElementById('loadingImg').style.visibility = "visible";
}
initCount = true;
if (dynamicGridObjs[gridNo].lastFilterOperation.length > 0) {
dynamicGridObjs[gridNo].filterOperation = dynamicGridObjs[gridNo].lastFilterOperation.slice();
} else {
dynamicGridObjs[gridNo].filterOperation = new Array();
}
if (dynamicGridObjs[gridNo].column.length != undefined && dynamicGridObjs[gridNo].column.length > 0){
reSetOrder(gridNo); /* multi order by */
loadSearch(gridNo);
}
else {
createGridHeader(gridNo);
}
} catch (e) {
// alert("Create Dynamic Grid :"+ e);
}
}
function refreshDynamicGrid(gridNo) {
try {
dynamicGridObjs[gridNo].currentPageNo = 0;
gridIndex = gridNo;
initCount = true;
dynamicGridObjs[gridNo].filterOperation = new Array();
// createGridHeader(gridNo);
loadSearch(gridNo);
} catch (e) {
// alert("Create Dynamic Grid :"+ e);
}
}
// function reDrawGrid(){
// try{
// drawGrid();
// }catch(e){
// alert(e);
// }
// }
// ==================== for Drawing Grid =======================================
function drawGrid(gridNo) {
initGrid(gridNo);
findHeaderAction(gridNo);
createHeader(gridNo);
reSetOrder(gridNo); /* multi order by */
createFooter(gridNo);
loadSearch(gridNo);
// getData();
}
function callNextGrid() {
try{
if (dynamicGridObjs[gridIndex].nextGrid != "") {
eval(dynamicGridObjs[gridIndex].nextGrid);
}
}catch(e){
// alert(""+e);
}
}
function initGrid(gridNo) {
tableName = dynamicGridObjs[gridNo].gridObj + "table";
var divString = "<span class='pageTitle'>"
+ dynamicGridObjs[gridNo].gridTitle + "</span>";
var tableString = "<table id='"
+ tableName
+ "' width='100%' cellspacing='0' cellpadding='0' border='0' class='wiget'></table>";
document.getElementById(dynamicGridObjs[gridNo].gridObj).innerHTML = divString;
document.getElementById(dynamicGridObjs[gridNo].gridObj).innerHTML += tableString;
}
function findHeaderAction(gridNo) {
try{
dynamicGridObjs[gridNo].leftHeaderContent="";
dynamicGridObjs[gridNo].rightHeaderContent="";
dynamicGridObjs[gridNo].leftHeaderAction=0;
dynamicGridObjs[gridNo].leftRowAction =0;
dynamicGridObjs[gridNo].rightHeaderAction=0;
dynamicGridObjs[gridNo].rightRowAction=0;
for (i = 0; i < dynamicGridObjs[gridNo].actionList.length; i++) {
if (dynamicGridObjs[gridNo].actionList[i].isActive == true) {
if (dynamicGridObjs[gridNo].actionList[i].isHeader == true) {
if (dynamicGridObjs[gridNo].actionList[i].direction =="L"){
dynamicGridObjs[gridNo].leftHeaderAction++;
dynamicGridObjs[gridNo].leftHeaderContent+= "<span dir='rtl' align='right'><img src='"
+ dynamicGridObjs[gridNo].actionList[i].imagePath
+ "'onclick='"
+ setMethod(dynamicGridObjs[gridNo].actionList[i].functionName)
+ "' style='border: none;cursor :pointer;' width=\"17px\" height=\"17px \" title='"
+ dynamicGridObjs[gridNo].actionList[i].actionName
+ "' /></span>";
}else if (dynamicGridObjs[gridNo].actionList[i].direction =="R"){
dynamicGridObjs[gridNo].rightHeaderAction++;
dynamicGridObjs[gridNo].rightHeaderContent += "<span dir='rtl' align='right'><img src='"
+ dynamicGridObjs[gridNo].actionList[i].imagePath
+ "'onclick='"
+ setMethod(dynamicGridObjs[gridNo].actionList[i].functionName)
+ "' style='border: none;cursor :pointer;' width=\"17px\" height=\"17px \" title='"
+ dynamicGridObjs[gridNo].actionList[i].actionName
+ "' /></span>";
}
} else{
if (dynamicGridObjs[gridNo].actionList[i].direction =="L"){
dynamicGridObjs[gridNo].leftRowAction ++;
}else if (dynamicGridObjs[gridNo].actionList[i].direction =="R"){
dynamicGridObjs[gridNo].rightRowAction++;
}
}
}
}
if(dynamicGridObjs[gridNo].leftRowAction == 0){
dynamicGridObjs[gridNo].column[0].width= ""+((dynamicGridObjs[gridNo].leftHeaderAction * 2)) + "%";
}else{
dynamicGridObjs[gridNo].column[0].width = ""+ ((dynamicGridObjs[gridNo].leftRowAction * 3)) + "%";
}
if (dynamicGridObjs[gridNo].rightRowAction == 0){
dynamicGridObjs[gridNo].column[dynamicGridObjs[gridNo].column.length - 1].width = ""
+ ((dynamicGridObjs[gridNo].rightHeaderAction * 2) ) + "%";
}
else{
dynamicGridObjs[gridNo].column[dynamicGridObjs[gridNo].column.length - 1].width = ""
+ ((dynamicGridObjs[gridNo].rightRowAction * 3) ) + "%";
}
}catch(e){
// alert(e);
}
}
function createHeader(gridNo) {
try {
var tableName = dynamicGridObjs[gridNo].gridObj + "table";
var row = document.getElementById(tableName).insertRow(0);
row.className = "cellHeader";
var counter=0;
for (i = 0; i <dynamicGridObjs[gridNo].column.length; i++) {
if(i==0){
if(dynamicGridObjs[gridNo].leftHeaderAction >0){
var cell = row.insertCell(counter++);
cell.colSpan =dynamicGridObjs[gridNo].leftRowAction;
cell.innerHTML = dynamicGridObjs[gridNo].column[i].title + " " + dynamicGridObjs[gridNo].leftHeaderContent;
}else if(dynamicGridObjs[gridNo].leftRowAction >0){
var cell = row.insertCell(counter++);
cell.colSpan =dynamicGridObjs[gridNo].leftRowAction;
cell.width="5%";
cell.innerHTML = dynamicGridObjs[gridNo].column[i].title;
}
}
else if (i < dynamicGridObjs[gridNo].column.length - 1) {
var cell = row.insertCell(counter++);
if(dynamicGridObjs[gridNo].sortType==0){
cell.innerHTML=""+dynamicGridObjs[gridNo].column[i].title;
}
else{
cell.innerHTML = "<a style=\"border: none;padding-right:5px;cursor: pointer;text-decoration: none;\" onclick=\"javascript:sortOn('"
+ dynamicGridObjs[gridNo].column[i].attribute
+ "',"
+ gridNo
+ ")\" ><img title=\"Sort\"; style=\"border: none; float : right;padding-right :2px;cursor: pointer;\" id=\""
+ gridNo
+ "_"
+ dynamicGridObjs[gridNo].column[i].attribute
+ "Img\" width=\"11px\" height=\"11px\" src=\"./js/lib/fw/images/sort_0.gif\" />"
+ " "
+ dynamicGridObjs[gridNo].column[i].title
+ "</a>";
}
cell.style.width = dynamicGridObjs[gridNo].column[i].width;
} else if (i == dynamicGridObjs[gridNo].column.length - 1){
if(dynamicGridObjs[gridNo].rightHeaderAction >0){
var cell = row.insertCell(counter++);
cell.colSpan =dynamicGridObjs[gridNo].rightRowAction;
cell.innerHTML = dynamicGridObjs[gridNo].column[i].title + " " + dynamicGridObjs[gridNo].rightHeaderContent;
}else if(dynamicGridObjs[gridNo].rightRowAction >0){
var cell = row.insertCell(counter++);
cell.colSpan =dynamicGridObjs[gridNo].rightRowAction;
cell.width="5%";
cell.innerHTML = dynamicGridObjs[gridNo].column[i].title;
}
}
}
} catch (e) {
// alert("Create Header : "+e);
}
}
function createFooter(gridNo) {
try{
var tableName = dynamicGridObjs[gridNo].gridObj + "table";
var tableString = "<table border='0' cellspacing='0' cellpadding='0'><tr class='tablePageInfo' >"
+ "<td onclick=\"openSearchWindow('searchPanel"
+ gridNo
+ "')\" title=\"Search\"><img style=\"border: none; padding-left: 10px; padding-right: 10px;\" width=\"16px\" height=\"16px\" src=\"./js/lib/fw/images/search.png\" id=\"searchButton\" /></td>"
+ "<td><a href=\"javascript:reDrawGrid("
+ gridNo
+ ");\" title=\"Refresh\"> <img style=\"border: none;\" width=\"14px\" height=\"12px\" src=\"./js/lib/fw/images/refresh.png\" /></a></td>"
+ "<td style=\"color:#444444;\"> Display: </td>"
+ "<td><select title='Select number of rows to view in grid' id='selPageLength_"
+ gridNo
+ "' name='selPageLength_"
+ gridNo
+ "' style='width:60px' onchange='selectPageLength("
+ gridNo
+ ")'padding-left: 10px; ></select></td><td></td>";
if (dynamicGridObjs[gridNo].disableCount) {
tableString += "<td></td>";
} else {
tableString += "<td><a href=\"javascript:firstPage("
+ gridNo
+ ")\" title=\"First Page\"> <img style=\"border: none; padding-left: 10px;\" width=\"12px\" height=\"12px\" src=\"./js/lib/fw/images/x-left.png\" /></a></td>";
}
tableString += "<td> </td>"
+ "<td><a href=\"javascript:priPage("
+ gridNo
+ ")\" title=\"Previous\"> <img style=\"border: none;\" width=\"12px\" height=\"12px\" src=\"./js/lib/fw/images/left.png\" /></a></td>"
+ "<td style=\"color:#444444;\"> Page: </td>"
+ "<td ><input title='Enter Page' type='text' id='pageNo_" + gridNo
+ "' ";
if (dynamicGridObjs[gridNo].disableCount) {
tableString += " disabled='disabled' ";
tableString += "size='4' onkeypress='pageSwitch(event,"
+ gridNo
+ ")' style='width:40px;color: black;'/></td>";
} else {
tableString += "size='4' onkeypress='pageSwitch(event,"
+ gridNo
+ ")' style='width:40px;background-color: white;color: black;'/></td>";
}
tableString += "<td> </td>"
+ "<td><a href=\"javascript:nextPage("
+ gridNo
+ ")\" title=\"Next\"> <img style=\"border: none;\" width=\"12px\" height=\"12px\" src=\"./js/lib/fw/images/right.png\" /></a></td>"
+ "<td> </td>";
if (dynamicGridObjs[gridNo].disableCount) {
tableString += "<td></td>";
} else {
tableString += "<td><a href=\"javascript:lastPage("
+ gridNo
+ ")\" title=\"Last Page\"> <img style=\"border: none;\" width=\"12px\" height=\"12px\" src=\"./js/lib/fw/images/x-right.png\" /></a></td>";
}
tableString += "<td> </td>"
+ "<td width='100%' align=\"right\"><span id='pageInfo_" + gridNo
+ "' style='color: #999999; padding-right: 5px'></span></td>"
+"</tr></tbody></table><div id='lodingPanel_"+gridNo+"'></div>" ;
var row = document.getElementById(tableName).insertRow(
document.getElementById(tableName).rows.length);
row.className = "cellHeader";
var cell = row.insertCell(0);
var limit=dynamicGridObjs[gridNo].column.length;
var left =dynamicGridObjs[gridNo].rightRowAction;
var right =dynamicGridObjs[gridNo].leftRowAction;
if ((dynamicGridObjs[gridNo].leftHeaderAction >0 || left >0) && ( dynamicGridObjs[gridNo].rightHeaderAction >0 || right >0)){
cell.colSpan = (limit+ left + right)-2;
}else if (dynamicGridObjs[gridNo].leftHeaderAction >0 || left >0){
cell.colSpan = (limit+ left)-2;
}else if ( dynamicGridObjs[gridNo].rightHeaderAction >0 || right >0){
cell.colSpan = (limit+ right)-2;
}
else {
cell.colSpan = limit-2;
}
cell.innerHTML = tableString;
i = 10;
while (i <= 250) {
var itemOption = document.createElement('option');
itemOption.text = i;
itemOption.value = i;
if (dynamicGridObjs[gridNo].recordLength == i)
itemOption.selected = true;
document.getElementsByName("selPageLength_" + gridNo)[0].options.add(
itemOption, i);
if (i < 50)
i += 5;
else
i += 50;
}
var row = document.getElementById(tableName).insertRow(
document.getElementById(tableName).rows.length - 1);
row.setAttribute("id", "searchPanel" + gridNo);
var counter=0;
if(dynamicGridObjs[gridNo].leftRowAction >0 || dynamicGridObjs[gridNo].leftHeaderAction >0){
var cell = row.insertCell(counter++);
cell.style.width = dynamicGridObjs[gridNo].column[0].width;
cell.colSpan =dynamicGridObjs[gridNo].leftRowAction;
cell.innerHTML = "";
}
for (var j = 1; j < dynamicGridObjs[gridNo].column.length-1; j++) {
var cell = row.insertCell(counter++);
cell.style.width = dynamicGridObjs[gridNo].column[j].width;
if (dynamicGridObjs[gridNo].column[j].datatype != "Date" && dynamicGridObjs[gridNo].column[j].datatype != "image" ) {
cell.innerHTML = "<input type=\"text\" id =\"" + gridNo + "_" + j
+ "\" name=\"" + gridNo + "_" + j
+ "\" onkeypress=\"performFilter(event," + gridNo
+ ")\" style=\" width :100%\" />";
cell.className = "cellBorder";
} else {
cell.innerHTML = "<input type=\"text\" id =\"" + gridNo + "_" + j
+ "\" name=\"" + gridNo + "_" + j
+ "\" style=\"visibility:hidden;width:100%;\" />";
}
}
if (dynamicGridObjs[gridNo].rightRowAction >0 || dynamicGridObjs[gridNo].rightHeaderAction >0){
var cell = row.insertCell(counter++);
cell.style.width = dynamicGridObjs[gridNo].column[dynamicGridObjs[gridNo].column.length-1].width;
cell.colSpan =dynamicGridObjs[gridNo].rightRowAction;
cell.innerHTML = "";
}
openSearchWindow("searchPanel" + gridNo);
}
catch(e){
alert(e);
}
}
function loadData(genericlist, gridNo) {
try {
tableName = tableName = dynamicGridObjs[gridNo].gridObj + "table";
try {
while (document.getElementById(tableName).rows.length > 3)
document.getElementById(tableName).deleteRow(1);
} catch (e) {
//drawGrid();
}
var loopEnd = genericlist.list.length;
if (dynamicGridObjs[gridNo].disableCount
&& loopEnd > dynamicGridObjs[gridNo].recordLength) {
loopEnd--;
}
for (rowId = 0; rowId < loopEnd; rowId++) {
var rowData = genericlist.list[rowId];
var row = document.getElementById(tableName).insertRow(rowId + 1);
if (rowId % 2 == 0) {
row.className = "cellEvenRow";
} else {
row.className = "cellOddRow";
}
var cellCounter = 0;
/* conditional action display */
if (dynamicGridObjs[gridNo].leftRowAction > 0) {
for (var k = 0; k < dynamicGridObjs[gridNo].actionList.length; k++) {
var Action = dynamicGridObjs[gridNo].actionList[k];
if (Action.isHeader == false && Action.isActive == true && Action.direction == "L" ) {
var cell = row.insertCell(cellCounter++);
cell.className = "cellBorder";
// cell.width = "1%";
cell.style.textAlign="center";
if((Action.bindProperty=='')||(Action.bindProperty!='' && (""+rowData[Action.bindProperty])=="true")){
cell.innerHTML = "<img src=\""
+ Action.imagePath
+ "\" onClick=\""
+ setMethod(Action.functionName, rowData)
+ "\" title=\""
+ Action.actionName
+ "\" style=\"border: none;cursor :pointer;\" width=\"18px\" height=\"16px \" />";
}
else{
cell.innerHTML = "";
}
}
}
} else if (dynamicGridObjs[gridNo].leftHeaderAction > 0) {
var cell = row.insertCell(cellCounter++);
cell.className = "cellBorder";
cell.innerHTML = "";
}
/* conditional action display */
for (j = 1; j < dynamicGridObjs[gridNo].column.length - 1; j++) {
var attr = dynamicGridObjs[gridNo].column[j].attribute;
var attrTitle = dynamicGridObjs[gridNo].column[j].title;
if (attrTitle.search("mm:ss") > -1) {
rowData[attr] = changeToMins(rowData[attr]);
}
var cell = row.insertCell(cellCounter++);
cell.className = "cellBorder";
cell.style.width = dynamicGridObjs[gridNo].column[j].width;
if (dynamicGridObjs[gridNo].column[j].datatype == "double"
|| dynamicGridObjs[gridNo].column[j].datatype == "long"
|| dynamicGridObjs[gridNo].column[j].datatype == "int") {
cell.style.textAlign = "right";
rowData[attr] = rowData[attr];
}
if (attr == "speed") {
if (parseFloat(rowData[attr]) < 0.10) {
// cell.style.color = "black";
// cell.style.backgroundColor= "gray";
cell.style.fontWeight = "bold";
rowData[attr] = "<table border=0><tr><td style='backgroundColor:gray;width:16px'> </td><td style='width:100%' align='right'>"
+ rowData[attr] + "</td></tr></table>";
} else if (parseFloat(rowData[attr]) < 20.01) {
// cell.style.color = "#FFFFFF";
// cell.style.backgroundColor = "red";
cell.style.fontWeight = "bold";
rowData[attr] = "<table border=0 width=100%><tbody><tr><td style='background-color:red;width:16px'> </td><td style='width:100%' align='right'>"
+ rowData[attr] + "</td></tr></tbody></table>";
} else if (parseFloat(rowData[attr]) < 35.01) {
// cell.style.color = "black";
// cell.style.backgroundColor = "orange";
cell.style.fontWeight = "bold";
rowData[attr] = "<table border=0 width=100%><tbody><tr><td style='background-color:orange;width:16px'> </td><td style='width:100%' align='right'>"
+ rowData[attr] + "</td></tr></tbody></table>";
} else if (parseFloat(rowData[attr]) < 50.01) {
// cell.style.color = "black";
// cell.style.backgroundColor = "yellow";
cell.style.fontWeight = "bold";
rowData[attr] = "<table border=0 width=100%><tbody><tr><td style='background-color:yellow;width:16px'> </td><td style='width:100%' align='right'>"
+ rowData[attr] + "</td></tr></tbody></table>";
} else {
// cell.style.color = "#FFFFFF";
// cell.style.backgroundColor = "green";
cell.style.fontWeight = "bold";
rowData[attr] = "<table border=0 width=100%><tbody><tr><td style='background-color:green;width:16px'> </td><td></td><td style='width:100%' align='right'>"
+ rowData[attr] + "</td></tr></tbody></table>";
}
}
if (attr == "linkConfigurationId.direction") {
cell.style.textAlign = "center";
}
if (dynamicGridObjs[gridNo].column[j].datatype == "double"
|| dynamicGridObjs[gridNo].column[j].datatype == "long"
|| dynamicGridObjs[gridNo].column[j].datatype == "int") {
cell.innerHTML = rowData[attr];
}
cell.innerHTML = rowData[attr];
if (cell.innerHTML == ' undefined'
|| cell.innerHTML == 'undefined '
|| cell.innerHTML == 'undefined') {
cell.innerHTML = "";
}
}
/* conditional action display */
if (dynamicGridObjs[gridNo].rightRowAction != 0) {
for (var k = 0; k < dynamicGridObjs[gridNo].actionList.length; k++) {
var Action = dynamicGridObjs[gridNo].actionList[k];
if (Action.isHeader == false && Action.isActive == true && Action.direction == "R" ) {
var cell = row.insertCell(cellCounter++);
cell.className = "cellBorder";
cell.width = "1%";
cell.style.textAlign="center";
if((Action.bindProperty=='')||(Action.bindProperty!='' && (""+rowData[Action.bindProperty])=="true")){
cell.innerHTML = "<img src=\""
+ Action.imagePath
+ "\" onClick=\""
+ setMethod(Action.functionName, rowData)
+ "\" title=\""
+ Action.actionName
+ "\" style=\"border: none;cursor :pointer;\" width=\"18px\" height=\"16px \" />";
}else{
cell.innerHTML = "";
}
}
}
} else if (dynamicGridObjs[gridNo].rightHeaderAction > 0) {
var cell = row.insertCell(cellCounter++);
cell.className = "cellBorder";
cell.innerHTML = "";
}
/* conditional action display */
}
$("#" + tableName).colResizable({
disable : true
});
$("#" + tableName).colResizable({
liveDrag : true,
draggingClass : "dragging",
gripInnerHtml : "<div class='grip'></div>"
});
if (!dynamicGridObjs[gridNo].disableCount && initCount == true) {
loadCount(gridNo);
} else if (dynamicGridObjs[gridNo].disableCount && dynamicGridObjs[gridNo].reDraw == true) {
callNextGrid();
dynamicGridObjs[gridNo].reDraw = false;
}
// var
// row=document.getElementById(tableName).insertRow(document.getElementById(tableName).rows.length-1);
// row.setAttribute("id","searchPanel"+gridNo);
// for(j=0;j<dynamicGridObjs[gridNo].column.length+rowAction-1;j++){
// var cell= row.insertCell(j);
// cell.className="cellBorder";
// if(j<dynamicGridObjs[gridNo].column.length-1 &&
// dynamicGridObjs[gridNo].column[j].datatype!="Date")
// cell.innerHTML="<input type=\"text\" id =\""+gridNo+"_"+j+"\"
// name=\""+gridNo+"_"+j+"\"
// onkeypress=\"performFilter(event,"+gridNo+")\" />";
// else
// cell.innerHTML="<input type=\"text\" id =\""+gridNo+"_"+j+"\"
// name=\""+gridNo+"_"+j+"\" style=\"visibility:hidden;width:1px;\" />";
// }
// openSearchWindow("searchPanel"+gridNo);
if(document.getElementById('loadingImg')){
document.getElementById('loadingImg').style.visibility = "hidden";
}
} catch (e) {
// alert("Load Data :" + e);
}
}
function changeToMins(rowVal){
if(rowVal!='NaN' && rowVal!=undefined){
rowVal+='';
var str=rowVal.split(".");
if(str.length>1){
var ss="";
var val="";
if(str[1].length==1){
val=parseInt(str[1]+"0")*0.60;
ss=roundNumber(val,0)+'';
}else if(str[1].length==2){
val=parseInt(str[1])*0.60;
ss=roundNumber(val,0)+'';
}else{
val=str[1].substring(0,2);
val=parseInt(val)*0.60;
ss = roundNumber(val, 0)+'';
}
if(ss.length==1){
ss="0"+ss;
}else if(ss.length>2){
ss=ss.substring(0, 2);
}
return str[0]+":"+ss;
}else{
return str[0]+":"+"00";
}
}else{
return "0:00";
}
}
function setMethod(method, rowValue) {
if (rowValue == undefined)
return method;
var start = false;
attribute = "";
beforeAtt = 0;
afterAtt = 0;
attributes = new Array();
otherAttribute = new Array();
for (i = 0; i < method.length; i++) {
if (method.substring(i, i + 1) == "}") {
start = false;
attributes[attributes.length] = attribute;
afterAtt = i + 1;
}
if (start == true) {
attribute += method.substring(i, i + 1);
}
if (method.substring(i, i + 1) == "{") {
otherAttribute[otherAttribute.length] = method.substring(afterAtt,
i);
attribute = "";
start = true;
beforeAtt = i;
}
}
otherAttribute[otherAttribute.length] = method.substring(afterAtt,
method.length);
str = ""
for (i = 0; i < otherAttribute.length - 1; i++) {
str += otherAttribute[i];
if (i < attributes.length)
str += rowValue[attributes[i]];
}
str += otherAttribute[otherAttribute.length - 1];
return str;
// return method.substring(0,beforeAtt)+rowValue[attribute]+
// method.substring(afterAtt,method.length);
}
// function setMethod(method,rowValue){
// if(rowValue==undefined)
// return method;
// var start=false;
// attribute="";
// beforeAtt=0;
// afterAtt=0;
//
// for(i=0;i<method.length;i++){
// if(method.substring(i,i+1)=="}"){
// start=false;
// afterAtt=i+1;
// }
// if(start==true){
// attribute+=method.substring(i,i+1);
// }
// if(method.substring(i,i+1)=="{"){
// start=true;
// beforeAtt=i;
// }
// }
// return method.substring(0,beforeAtt)+rowValue[attribute]+
// method.substring(afterAtt,method.length);
//
// }
// ======================== get data for grid ===============================
function loadSearch(no) {
try {
document.getElementById("lodingPanel_" + no).innerHTML="<div id=\"processDiv_"+no+"\" title=\"Please Wait...\">"
+"<table border=\"0\">"
+"<tr>"
+"<td align=\"center\">"
+"<img src=\"js/lib/images/loading.gif\" width=\"25px\" align=\"middle\">"
+"</td>"
+"</tr>"
+"<tr>"
+"<td align=\"center\">"
+"<h3 id=\"msgDialog\" >"
+"<span id=\"processMsg\">"
+"<font color=\"#6255ED\">Loading Data .... Please Wait</font>"
+"</span>"
+"</h3>"
+"</td>"
+"</tr>"
+"</table>"
+"</div>";
$('#processDiv_'+no).dialog({
autoOpen : false,
width : 250,
height : 130,
resizable : false,
closeOnEscape : false,
modal : true,
open : function(event, ui) {
$(".ui-dialog-titlebar").hide();
},close : function(event, ui) {
$.event.remove(this);
$(".ui-dialog-titlebar").show();
}
});
if (dynamicGridObjs[no].loadingDialog) {
$('#processDiv_'+no).dialog('open');
}
search = jQuery.extend(true, {}, dynamicGridObjs[no].interSearch);
for (i = 0; i < dynamicGridObjs[no].filterOperation.length; i++) {
search.operation[search.operation.length] = dynamicGridObjs[no].filterOperation[i];
}
if(dynamicGridObjs[no].retainFilterSearch==true){
dynamicGridObjs[no].lastFilterOperation = dynamicGridObjs[no].filterOperation.slice();
dynamicGridObjs[no].lastPageStatus=dynamicGridObjs[no].currentPageNo;
}
currentPageNo = dynamicGridObjs[no].currentPageNo;
recordLength = dynamicGridObjs[no].recordLength;
totalRecords = dynamicGridObjs[no].totalRecords;
if (dynamicGridObjs[no].disableCount) {
addPaging(currentPageNo * recordLength, recordLength + 1);
} else {
addPaging(currentPageNo * recordLength, recordLength);
}
/* multi order by */
if(dynamicGridObjs[no].sortType==1){
if (dynamicGridObjs[no].orderByOperant == "") {
addOrderBy("id", false);
} else {
addOrderBy(dynamicGridObjs[no].orderByOperant,
dynamicGridObjs[no].assending);
setOrderImage(dynamicGridObjs[no].orderByOperant, no);
}
}else if(dynamicGridObjs[no].sortType==2){
for(var i=dynamicGridObjs[no].sortList.length-1;i>=0;i--){
addMultiOrder(dynamicGridObjs[no].sortList[i].operant,dynamicGridObjs[no].sortList[i].assending);
}
}
/* multi order by */
var getUrl = dynamicGridObjs[no].urlForGridData;
if(dynamicGridObjs[no].isPost){
$.post(getUrl,{search :decodeURI(createSearchJson()),userId: getCookie("userId"),m:Math.random()},function (data){returnDataFillGrid(data,no)});
}else{
getUrl +="?search="
+ createSearchJson() + "&userId=" + getCookie("userId") + "&m="
+ Math.random();
$.get(getUrl,function (data){returnDataFillGrid(data,no)});
}
} catch (e) {
alert("Load Search :" + e);
}
}
function returnDataFillGrid(data,no) {
genericlist = eval('(' + data + ')');
loadData(genericlist, no);
$('#processDiv_'+no).dialog('close').remove();
document.getElementById("pageNo_" + no).value = currentPageNo + 1;
if (dynamicGridObjs[no].disableCount) {
var rec = genericlist.list.length;
loadDummyCount(no, rec);
} else {
currentPageNo=dynamicGridObjs[no].currentPageNo;
document.getElementById("pageNo_" + no).value = currentPageNo + 1;
var rec = currentPageNo * recordLength;
if (genericlist.list.length > 0) {
if (totalRecords != undefined
&& (rec + recordLength) > totalRecords)
document.getElementById("pageInfo_"
+ no).innerHTML = " "
+ (rec + 1) + " to "
+ totalRecords + " out of "
+ totalRecords;
else if (totalRecords != undefined)
document.getElementById("pageInfo_"
+ no).innerHTML = " "
+ (rec + 1)
+ " to "
+ ((currentPageNo * recordLength) + recordLength)
+ " out of " + totalRecords;
}
}
}
function loadDummyCount(gridNo, rec) {
if (rec < dynamicGridObjs[gridNo].recordLength + 1) {
totalRecords = ((dynamicGridObjs[gridNo].currentPageNo + 1) * dynamicGridObjs[gridNo].recordLength);
totalPages = dynamicGridObjs[gridNo].currentPageNo;
} else {
totalRecords = 1 + ((dynamicGridObjs[gridNo].currentPageNo + 1) * dynamicGridObjs[gridNo].recordLength);
totalPages = dynamicGridObjs[gridNo].currentPageNo + 1;
}
dynamicGridObjs[gridNo].totalRecords = totalRecords;
dynamicGridObjs[gridNo].totalPages = totalPages;
}
function loadCount(no) {
try {
document.getElementById("pageNo_" + no).value = dynamicGridObjs[no].currentPageNo + 1;
search = jQuery.extend(true, {}, dynamicGridObjs[no].interSearch);
search.orderBy=new seOrderBy();
for (i = 0; i <dynamicGridObjs[no].filterOperation.length; i++)
search.operation[search.operation.length] = dynamicGridObjs[no].filterOperation[i];
search.count = true;
var getUrl = dynamicGridObjs[no].urlForGridData
if(dynamicGridObjs[no].isPost){
$.post(getUrl,{search :decodeURI(createSearchJson()),userId: getCookie("userId"),m:Math.random()},function(data) {returnDataForCount(data,no)});
}else{
getUrl +="?search="
+ createSearchJson() + "&userId=" + getCookie("userId") + "&m="
+ Math.random();
$.get(getUrl,function(data) {returnDataForCount(data,no)});
}
} catch (e) {
// alert("Load Count :"+e);
}
}
function returnDataForCount(data,no){
genericlist = eval('(' + data + ')');
if (genericlist.list.length > 0) {
totalRecords = parseInt(genericlist.list[0]);
dynamicGridObjs[no].totalRecords = genericlist.list[0];
} else {
totalRecords = 0;
dynamicGridObjs[no].totalRecords = 0;
}
dynamicGridObjs[no].totalPages = parseInt((totalRecords / recordLength) - 1);
if (totalRecords % recordLength > 0) {
dynamicGridObjs[no].totalPages++;
}
var rec = currentPageNo * recordLength;
if (totalRecords == 0) {
document.getElementById("pageNo_" + no).value = 1;
document.getElementById("pageInfo_" + no).innerHTML = " ";
} else if (totalRecords != undefined
&& (rec + recordLength) > totalRecords)
document.getElementById("pageInfo_" + no).innerHTML = " "
+ (rec + 1)
+ " to "
+ totalRecords
+ " out of " + totalRecords;
else if (totalRecords != undefined)
document.getElementById("pageInfo_" + no).innerHTML = " "
+ (rec + 1)
+ " to "
+ ((currentPageNo * recordLength) + recordLength)
+ " out of " + totalRecords;
initCount = false;
if (dynamicGridObjs[no].reDraw == true){
callNextGrid();
}
}
function reDrawGrid(gridNo) {
dynamicGridObjs[gridNo].filterOperation= new Array();
dynamicGridObjs[gridNo].currentPageNo = 0;
initCount = true;
for (j = 1; j < dynamicGridObjs[gridNo].column.length - 1; j++) {
if (j < dynamicGridObjs[gridNo].column.length - 1
&& dynamicGridObjs[gridNo].column[j].datatype != "Date") {
document.getElementById("" + gridNo + "_" + j).value = "";
}
}
reSetOrder(gridNo); // multi order by
addSearchFilterOperations("ne", "id", "0");
loadSearch(gridNo);
}
// ===================================================================================
// ==================== add serach parameter to request ======================
// ---------------------- used for grid only ---------------------------
function seInputOnlyProjection(gridNo, seInputTemp) {
var search = jQuery.extend(true, {}, seInputTemp);
try {
search.operation = new Array();
search.orOperation = new Array();
search.orAndOperation = new Array();
search.range = new Array();
search.orRange = new Array();
search.orderBy = new seOrderBy();
search.groupBy = "";
search.count = false;
search.multiOrderBy= new Array(); // multi order by
search.aggrigation = new Array();
search.paging = new sePaging();
} catch (e) {
// alert(e);
}
return search;
}
// ------------------------------------------------------------------------
// -------------------- for static for grid which initalize before grid creation
// ----------
function addSearchOperations(operator, operant, value, gridNo) {
try {
var operation = new seOperation();
operation.operator = operator;
operation.operant = operant;
operation.value = value;
dynamicGridObjs[gridNo].interSearch.operation[dynamicGridObjs[gridNo].interSearch.operation.length] = operation;
} catch (e) {
// alert("Search Operation : "+ e);
}
}
function addORSearchOperations(operator, operant, value, gridNo) {
try {
var operation = new seOperation();
operation.operator = operator;
operation.operant = operant;
operation.value = value;
dynamicGridObjs[gridNo].interSearch.orOperation[dynamicGridObjs[gridNo].interSearch.orOperation.length] = operation;
} catch (e) {
// alert("Search Operation : " + e);
}
}
function addOrAndSearchOperations(operator, operant, value, gridNo) {
try {
var operation = new seOperation();
operation.operator = operator;
operation.operant = operant;
operation.value = value;
dynamicGridObjs[gridNo].interSearch.orAndOperation[dynamicGridObjs[gridNo].interSearch.orAndOperation.length] = operation;
} catch (e) {
// alert("Search Operation : " + e);
}
}
function cerateRange(operant, start, end, gridNo) {
var range = new seRange();
range.operant = operant;
range.start = start;
range.end = end;
dynamicGridObjs[gridNo].interSearch.range[dynamicGridObjs[gridNo].interSearch.range.length] = range;
}
function createGridOrRange(operant, start, end, gridNo) {
var range = new seRange();
range.operant = operant;
range.start = start;
range.end = end;
dynamicGridObjs[gridNo].interSearch.orRange[dynamicGridObjs[gridNo].interSearch.orRange.length] = range;
}
function createGridAggrigation(name, property, gridNo) {
var aggri = new aggrigation();
aggri.functionName = name;
aggri.property = property;
dynamicGridObjs[gridNo].interSearch.aggrigation[dynamicGridObjs[gridNo].interSearch.aggrigation.length] = aggri;
}
// --------------------- for add when search filter perform after grid loaded
// -----------
function addSearchFilterOperations(operator, operant, value,gridNo) {
try {
var operation = new seOperation();
operation.operator = operator;
operation.operant = operant;
operation.value = value;
dynamicGridObjs[gridNo].filterOperation[dynamicGridObjs[gridNo].filterOperation.length] = operation;
} catch (e) {
// alert(e);
}
}
function addGridGroupBy(operant, gridNo) {
dynamicGridObjs[gridNo].interSearch.groupBy = operant;
}
// ================================================================================
// ================================
// called when enter pressed in filter textbox
// immediate added at top of navigation bar
// ====================================
function performFilter(e, gridNo) {
try {
var key = (typeof event != 'undefined') ? window.event.keyCode
: e.keyCode;
if (key == 13) {
dynamicGridObjs[gridNo].currentPageNo = 0;
dynamicGridObjs[gridNo].reDraw = false;
gridIndex = gridNo;
dynamicGridObjs[gridNo].filterOperation = new Array();
for (i = 1; i < dynamicGridObjs[gridNo].column.length - 1; i++) {
if (document.getElementById(gridNo + "_" + i).value != "") {
if (dynamicGridObjs[gridNo].column[i].datatype == "String")
addSearchFilterOperations("like",
dynamicGridObjs[gridNo].column[i].attribute,
document.getElementById(gridNo + "_" + i).value
+ "%",gridNo);
else
addSearchFilterOperations("eq",
dynamicGridObjs[gridNo].column[i].attribute,
document.getElementById(gridNo + "_" + i).value,gridNo);
}
// document.getElementById(gridNo+"_"+i).value = "";
}
initCount = true;
currentPageNo = 0;
openSearchWindow("searchPanel" + gridNo);
loadSearch(gridNo);
}
} catch (e) {
// alert(e);
}
}
//====================== for sorting ========================================================
function addDefaultMultiSorting(pSortOn,order,gridNo){
for(var i=0;i<dynamicGridObjs[gridNo].defaultMultiSorting.length;i++){
if(dynamicGridObjs[gridNo].defaultMultiSorting[i].operant== pSortOn){
return;
}
}
var newSortItem=new seOrderBy();
newSortItem.operant=pSortOn;
newSortItem.assending=order;
dynamicGridObjs[gridNo].defaultMultiSorting[dynamicGridObjs[gridNo].defaultMultiSorting.length]=newSortItem;
}
function setDefaultOrder(gridNo){
for(var i=0;i<dynamicGridObjs[gridNo].defaultMultiSorting.length;i++){
var idImg = gridNo + "_" + dynamicGridObjs[gridNo].defaultMultiSorting[i].operant+ "Img";
if(dynamicGridObjs[gridNo].defaultMultiSorting[i].assending == true){
document.getElementById(idImg).src = "./js/lib/fw/images/sort_2.gif";
document.getElementById(idImg).title = "Assending";
}else{
document.getElementById(idImg).src = "./js/lib/fw/images/sort_1.gif";
document.getElementById(idImg).title = "Desending";
}
dynamicGridObjs[gridNo].sortList[dynamicGridObjs[gridNo].sortList.length]=dynamicGridObjs[gridNo].defaultMultiSorting[i];
}
}
function reSetOrder(gridNo){
try {
if(dynamicGridObjs[gridNo].sortType== 0)
return;// true;
for (var i = 0; i < dynamicGridObjs[gridNo].column.length - 1; i++) {
if(dynamicGridObjs[gridNo].column[i].title=="Actions"){
continue;
}
var lIdImg = gridNo + "_" + dynamicGridObjs[gridNo].column[i].attribute+ "Img";
document.getElementById(lIdImg).src = "./js/lib/fw/images/sort_0.gif";
document.getElementById(lIdImg).title = "Sort";
}
dynamicGridObjs[gridNo].sortList= new Array();
setDefaultOrder(gridNo);
}catch(e){
// alert(e);
}
}
function sortOn(pSortOn, gridNo) {
try {
if(dynamicGridObjs[gridNo].sortType ==1){
orderByCol = pSortOn;
dynamicGridObjs[gridNo].orderByOperant = pSortOn;
initCount = true;
dynamicGridObjs[gridNo].currentPageNo = 0;
if (dynamicGridObjs[gridNo].orderByOperant == pSortOn) {
if (dynamicGridObjs[gridNo].assending == true) {
dynamicGridObjs[gridNo].assending = false;
orderByTF = false;
} else {
dynamicGridObjs[gridNo].assending = true;
orderByTF = true;
}
} else {
dynamicGridObjs[gridNo].orderByOperant = pSortOn;
dynamicGridObjs[gridNo].assending = true;
orderByTF = true;
}
}else if(dynamicGridObjs[gridNo].sortType ==2){
var idImg = gridNo + "_" + pSortOn + "Img";
for (var i=0;i<dynamicGridObjs[gridNo].sortList.length;i++){
if(dynamicGridObjs[gridNo].sortList[i].operant==pSortOn){
dynamicGridObjs[gridNo].sortList.splice(i,1);
}
}
if(document.getElementById(idImg).title == "Desending"){
document.getElementById(idImg).src = "./js/lib/fw/images/sort_0.gif";
document.getElementById(idImg).title = "Sort";
}else{
var newSortItem=new seOrderBy();
newSortItem.operant=pSortOn;
if(document.getElementById(idImg).title == "Sort"){
document.getElementById(idImg).src = "./js/lib/fw/images/sort_2.gif";
document.getElementById(idImg).title = "Assending";
newSortItem.assending=true;
}else{
document.getElementById(idImg).src = "./js/lib/fw/images/sort_1.gif";
document.getElementById(idImg).title = "Desending";
newSortItem.assending=false;
}
if(dynamicGridObjs[gridNo].sortList.length == 2) {
idImg = gridNo + "_" + dynamicGridObjs[gridNo].sortList[0].operant + "Img";
document.getElementById(idImg).src = "./js/lib/fw/images/sort_0.gif";
document.getElementById(idImg).title = "Sort";
dynamicGridObjs[gridNo].sortList.splice(0,1);
}
dynamicGridObjs[gridNo].sortList[dynamicGridObjs[gridNo].sortList.length]=newSortItem;
}
}
loadSearch(gridNo);
} catch (e) {
// alert(e);
}
}
function setOrderImage(operant, gridNo) {
for (i = 0; i < dynamicGridObjs[gridNo].column.length - 1; i++) {
if(dynamicGridObjs[gridNo].column[i].title=="Actions"){
continue;
}
var lIdImg = gridNo + "_" + dynamicGridObjs[gridNo].column[i].attribute+ "Img";
document.getElementById(lIdImg).src = "./js/lib/fw/images/sort_0.gif";
}
var idImg = gridNo + "_" + operant + "Img";
if (dynamicGridObjs[gridNo].assending == false) {
document.getElementById(idImg).src = "./js/lib/fw/images/sort_1.gif";
document.getElementById(idImg).title = "Desending";
} else {
document.getElementById(idImg).src = "./js/lib/fw/images/sort_2.gif";
document.getElementById(idImg).title = "Assending";
}
}
// ======================= paging =======================================================
function selectPageLength(id) {
initCount = true;
dynamicGridObjs[id].currentPageNo = 0;
dynamicGridObjs[id].recordLength = parseInt(document
.getElementById("selPageLength_" + id).value);
loadSearch(id);
}
function pageSwitch(e, id) {
if (e.keyCode == 13) {
dynamicGridObjs[id].currentPageNo = (parseInt(document
.getElementById("pageNo_" + id).value) * 1) - 1;
if (dynamicGridObjs[id].currentPageNo < 0) {
dynamicGridObjs[id].currentPageNo = 0;
}
if (dynamicGridObjs[id].currentPageNo > dynamicGridObjs[id].totalPages) {
dynamicGridObjs[id].currentPageNo = parseInt(dynamicGridObjs[id].totalPages);
}
loadSearch(id);
}
}
// =====================function for open search window ====================
function openSearchWindow(ids) {
try{
$("#" + ids).slideToggle("fast");
}catch(e){
// alert(e);
}
}
// ==================== function for navigation in grid ====================
function firstPage(id) {
if (dynamicGridObjs[id].currentPageNo > 0) {
dynamicGridObjs[id].currentPageNo = 0;
loadSearch(id);
}
}
function lastPage(id) {
if (dynamicGridObjs[id].currentPageNo != dynamicGridObjs[id].totalPages
&& dynamicGridObjs[id].totalRecords > (dynamicGridObjs[id].recordLength * (dynamicGridObjs[id].currentPageNo + 1))) {
dynamicGridObjs[id].currentPageNo = parseInt(dynamicGridObjs[id].totalPages);
loadSearch(id);
}
}
function priPage(id) {
if (dynamicGridObjs[id].currentPageNo > 0) {
dynamicGridObjs[id].currentPageNo--;
loadSearch(id);
}
}
function nextPage(id) {
if (dynamicGridObjs[id].currentPageNo < dynamicGridObjs[id].totalPages
&& dynamicGridObjs[id].totalRecords > (dynamicGridObjs[id].recordLength * (dynamicGridObjs[id].currentPageNo + 1))) {
dynamicGridObjs[id].currentPageNo++;
loadSearch(id);
}
}
// ===========================================================================
function addImageItem(isNew, attributeName, attributeValue, displayImage, url,gridNo) {
try {
if (isNew == true) {
dynamicGridObjs[gridNo].imageArray["" + attributeName] = new Array();
}
dynamicGridObjs[gridNo].imageArray["" + attributeName][""
+ attributeValue] = [ displayImage, url ];
} catch (e) {
// alert("Add Image error" + e);
}
}
function roundNumber(num, dec) {
var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
return result;
}
*
*/
var currentPageNo = 0;
var recordLength = 20;
var totalRecords = 100;
var tableName = "";
var url = "";
var headerAction = 0;
var headerContent = "";
var rowAction = 0;
var genericlist;
var totalPages = 0;
var searchOperations = new Array();
var ORSearchOperations = new Array();
var searchFilterOperations = new Array();
var orderByOperant = "";
var assending = true;
var initCount = false;
var orderByCol = "";
var orderByTF = true;
var loadingDialog=true;
// ======================== for classes =======================================
function gridAction() {
this.actionName = "";
this.functionName = "";
this.imagePath = "";
this.direction ="";
this.isActive = false;
this.isHeader = false;
this.bindProperty=""; /* conditional action display */
}
function gridColumn() {
this.title = "";
this.attribute = "";
this.datatype = "";
this.width = "";
}
function dynamicGrid() {
this.gridObj = "";
this.gridTitle = "";
this.className = "";
this.formId = "";
this.currentPageNo = 0;
this.recordLength = 100;
this.totalRecords = 100;
this.totalPages = 0;
this.disableCount = false;
this.retainFilterSearch=false;
this.column = new Array();
this.actionList = new Array();
this.filterOperation = new Array();
this.interSearch = new seInput();
this.lastFilterOperation = new Array();
this.imageArray = new Array();
this.lastPageStatus=0;
this.reDraw=true;
this.isPost=false;
this.sortType=0; /* multi order by */
this.assending = true;
this.leftHeaderAction=0;
this.leftRowAction =0;
this.rightHeaderAction=0;
this.rightRowAction=0;
this.leftHeaderContent="";
this.rightHeaderContent="";
this.orderByOperant = "";
this.urlForGridData = "";
this.nextGrid = "";
this.loadingDialog=true;
this.isLoaded=false;
this.sortList = new Array();
this.defaultMultiSorting= new Array();
}
var dynamicGridObj = new dynamicGrid();
var dynamicGridObjs = new Array();
//$(function() {
// $('#processDiv').dialog({
// autoOpen : false,
// width : 250,
// height : 130,
// resizable : false,
// closeOnEscape : false,
// modal : true,
// open : function(event, ui) {
// $(".ui-dialog-titlebar").hide()
// }
// });
//});
// ===================== for grid obj to grid array ==========================
function addGrid(dynamicGridObj) {
try {
for (i = 0; i < dynamicGridObjs.length; i++) {
if (dynamicGridObjs[i].gridObj == dynamicGridObj.gridObj
&& dynamicGridObjs[i].column.length != undefined
&& dynamicGridObjs[i].column.length > 0) {
dynamicGridObjs[i].interSearch = seInputOnlyProjection(i,
dynamicGridObjs[i].interSearch);
$('#processDiv_'+i).dialog('close').remove();
return i;
}
}
dynamicGridObjs[dynamicGridObjs.length] = dynamicGridObj;
return dynamicGridObjs.length - 1;
} catch (e) {
alert("This :" + e);
}
}
// ========================= for Grid Action List
// =====================================
function createActionsList(gridNo, actionName, functionName, imagePath,isHeader,direction,bindProperty) {
try {
var t = false;
for (j = 0; j < dynamicGridObjs[gridNo].actionList.length; j++) {
if (dynamicGridObjs[gridNo].actionList[j].actionName == actionName ) {
t = true;
break;
}
}
if (t != true) {
var tempGridAction = new gridAction();
tempGridAction.actionName = actionName;
tempGridAction.functionName = functionName;
tempGridAction.imagePath = imagePath;
tempGridAction.isHeader = isHeader;
tempGridAction.direction =direction;
tempGridAction.bindProperty=bindProperty;
dynamicGridObjs[gridNo].actionList[dynamicGridObjs[gridNo].actionList.length] = tempGridAction;
}
} catch (e) {
// alert("Add Action List : "+ e);
}
}
// ============= for Grid Column List ======================
function createColumn(gridNo, title, attribute, dataType, width) {
try {
var tempColumn = new gridColumn();
tempColumn.title = title;
tempColumn.attribute = attribute;
tempColumn.datatype = dataType;
tempColumn.width = width;
dynamicGridObjs[gridNo].column[dynamicGridObjs[gridNo].column.length] = tempColumn;
} catch (e) {
// alert("Create Column :"+ e);
}
}
// ==============================================================
function createGridHeader(gridNo) {
try {
var getUrl = dynamicGridObjs[gridNo].className + "&m=" + Math.random();
$
.get(
getUrl,
function(data) {
dynamicGridObjs[gridNo].column = new Array();
dynamicGridObjs[gridNo].interSearch.projection = new Array();
var genericlist = eval('(' + data + ')');
createColumn(gridNo, "Actions", "", "", "");
for (i = 0; i < genericlist.list.length; i++) {
createColumn(gridNo,
genericlist.list[i].attributeTitle,
genericlist.list[i].attributeName,
genericlist.list[i].attributeType,
genericlist.list[i].attributeWidth);
dynamicGridObjs[gridNo].interSearch.projection[dynamicGridObjs[gridNo].interSearch.projection.length] = genericlist.list[i].attributeName;
}
dynamicGridObjs[gridNo].interSearch.projection[dynamicGridObjs[gridNo].interSearch.projection.length] = "id";
createColumn(gridNo, "Actions", "", "", "");
createAccessList(gridNo);
});
} catch (e) {
// alert(e);
}
}
function createAccessList(gridNo) {
try {
if (dynamicGridObjs[gridNo].formId != undefined
&& dynamicGridObjs[gridNo].formId != "") {
var getUrl = dynamicGridObjs[gridNo].formId + "&m=" + Math.random();
$
.get(
getUrl,
function(data) {
for (i = 0; i < dynamicGridObjs[gridNo].actionList.length; i++) {
if (data
.indexOf(dynamicGridObjs[gridNo].actionList[i].actionName) > -1) {
dynamicGridObjs[gridNo].actionList[i].isActive = true;
}
}
drawGrid(gridNo);
});
} else {
for (i = 0; i < dynamicGridObjs[gridNo].actionList.length; i++)
dynamicGridObjs[gridNo].actionList[i].isActive = true;
drawGrid(gridNo);
}
} catch (e) {
// alert("Create Access List : "+e);
}
}
// ================== for Grid creation =======================================
function createDynamicGrid(gridNo) {
try {
if(dynamicGridObjs[gridNo].retainFilterSearch==true){
dynamicGridObjs[gridNo].currentPageNo=dynamicGridObjs[gridNo].lastPageStatus;
}else{
dynamicGridObjs[gridNo].currentPageNo = 0;
}
gridIndex = gridNo;
if(document.getElementById('loadingImg')){
document.getElementById('loadingImg').style.visibility = "visible";
}
initCount = true;
if (dynamicGridObjs[gridNo].lastFilterOperation.length > 0) {
dynamicGridObjs[gridNo].filterOperation = dynamicGridObjs[gridNo].lastFilterOperation.slice();
} else {
dynamicGridObjs[gridNo].filterOperation = new Array();
}
if (dynamicGridObjs[gridNo].column.length != undefined && dynamicGridObjs[gridNo].column.length > 0){
reSetOrder(gridNo); /* multi order by */
loadSearch(gridNo);
}
else {
createGridHeader(gridNo);
}
} catch (e) {
// alert("Create Dynamic Grid :"+ e);
}
}
function refreshDynamicGrid(gridNo) {
try {
dynamicGridObjs[gridNo].currentPageNo = 0;
gridIndex = gridNo;
initCount = true;
dynamicGridObjs[gridNo].filterOperation = new Array();
// createGridHeader(gridNo);
loadSearch(gridNo);
} catch (e) {
// alert("Create Dynamic Grid :"+ e);
}
}
// function reDrawGrid(){
// try{
// drawGrid();
// }catch(e){
// alert(e);
// }
// }
// ==================== for Drawing Grid =======================================
function drawGrid(gridNo) {
initGrid(gridNo);
findHeaderAction(gridNo);
createHeader(gridNo);
reSetOrder(gridNo); /* multi order by */
createFooter(gridNo);
loadSearch(gridNo);
// getData();
}
function callNextGrid() {
try{
if (dynamicGridObjs[gridIndex].nextGrid != "") {
eval(dynamicGridObjs[gridIndex].nextGrid);
}
}catch(e){
// alert(""+e);
}
}
function initGrid(gridNo) {
tableName = dynamicGridObjs[gridNo].gridObj + "table";
var divString = "<span class='pageTitle'>"
+ dynamicGridObjs[gridNo].gridTitle + "</span>";
var tableString = "<table id='"
+ tableName
+ "' width='100%' cellspacing='0' cellpadding='0' border='0' class='wiget'></table>";
document.getElementById(dynamicGridObjs[gridNo].gridObj).innerHTML = divString;
document.getElementById(dynamicGridObjs[gridNo].gridObj).innerHTML += tableString;
}
function findHeaderAction(gridNo) {
try{
dynamicGridObjs[gridNo].leftHeaderContent="";
dynamicGridObjs[gridNo].rightHeaderContent="";
dynamicGridObjs[gridNo].leftHeaderAction=0;
dynamicGridObjs[gridNo].leftRowAction =0;
dynamicGridObjs[gridNo].rightHeaderAction=0;
dynamicGridObjs[gridNo].rightRowAction=0;
for (i = 0; i < dynamicGridObjs[gridNo].actionList.length; i++) {
if (dynamicGridObjs[gridNo].actionList[i].isActive == true) {
if (dynamicGridObjs[gridNo].actionList[i].isHeader == true) {
if (dynamicGridObjs[gridNo].actionList[i].direction =="L"){
dynamicGridObjs[gridNo].leftHeaderAction++;
dynamicGridObjs[gridNo].leftHeaderContent+= "<span dir='rtl' align='right'><img src='"
+ dynamicGridObjs[gridNo].actionList[i].imagePath
+ "'onclick='"
+ setMethod(dynamicGridObjs[gridNo].actionList[i].functionName)
+ "' style='border: none;cursor :pointer;' width=\"17px\" height=\"17px \" title='"
+ dynamicGridObjs[gridNo].actionList[i].actionName
+ "' /></span>";
}else if (dynamicGridObjs[gridNo].actionList[i].direction =="R"){
dynamicGridObjs[gridNo].rightHeaderAction++;
dynamicGridObjs[gridNo].rightHeaderContent += "<span dir='rtl' align='right'><img src='"
+ dynamicGridObjs[gridNo].actionList[i].imagePath
+ "'onclick='"
+ setMethod(dynamicGridObjs[gridNo].actionList[i].functionName)
+ "' style='border: none;cursor :pointer;' width=\"17px\" height=\"17px \" title='"
+ dynamicGridObjs[gridNo].actionList[i].actionName
+ "' /></span>";
}
} else{
if (dynamicGridObjs[gridNo].actionList[i].direction =="L"){
dynamicGridObjs[gridNo].leftRowAction ++;
}else if (dynamicGridObjs[gridNo].actionList[i].direction =="R"){
dynamicGridObjs[gridNo].rightRowAction++;
}
}
}
}
if(dynamicGridObjs[gridNo].leftRowAction == 0){
dynamicGridObjs[gridNo].column[0].width= ""+((dynamicGridObjs[gridNo].leftHeaderAction * 2)) + "%";
}else{
dynamicGridObjs[gridNo].column[0].width = ""+ ((dynamicGridObjs[gridNo].leftRowAction * 3)) + "%";
}
if (dynamicGridObjs[gridNo].rightRowAction == 0){
dynamicGridObjs[gridNo].column[dynamicGridObjs[gridNo].column.length - 1].width = ""
+ ((dynamicGridObjs[gridNo].rightHeaderAction * 2) ) + "%";
}
else{
dynamicGridObjs[gridNo].column[dynamicGridObjs[gridNo].column.length - 1].width = ""
+ ((dynamicGridObjs[gridNo].rightRowAction * 3) ) + "%";
}
}catch(e){
// alert(e);
}
}
function createHeader(gridNo) {
try {
var tableName = dynamicGridObjs[gridNo].gridObj + "table";
var row = document.getElementById(tableName).insertRow(0);
row.className = "cellHeader";
var counter=0;
for (i = 0; i <dynamicGridObjs[gridNo].column.length; i++) {
if(i==0){
if(dynamicGridObjs[gridNo].leftHeaderAction >0){
var cell = row.insertCell(counter++);
cell.colSpan =dynamicGridObjs[gridNo].leftRowAction;
cell.innerHTML = dynamicGridObjs[gridNo].column[i].title + " " + dynamicGridObjs[gridNo].leftHeaderContent;
}else if(dynamicGridObjs[gridNo].leftRowAction >0){
var cell = row.insertCell(counter++);
cell.colSpan =dynamicGridObjs[gridNo].leftRowAction;
cell.width="5%";
cell.innerHTML = dynamicGridObjs[gridNo].column[i].title;
}
}
else if (i < dynamicGridObjs[gridNo].column.length - 1) {
var cell = row.insertCell(counter++);
if(dynamicGridObjs[gridNo].sortType==0){
cell.innerHTML=""+dynamicGridObjs[gridNo].column[i].title;
}
else{
cell.innerHTML = "<a style=\"border: none;padding-right:5px;cursor: pointer;text-decoration: none;\" onclick=\"javascript:sortOn('"
+ dynamicGridObjs[gridNo].column[i].attribute
+ "',"
+ gridNo
+ ")\" ><img title=\"Sort\"; style=\"border: none; float : right;padding-right :2px;cursor: pointer;\" id=\""
+ gridNo
+ "_"
+ dynamicGridObjs[gridNo].column[i].attribute
+ "Img\" width=\"11px\" height=\"11px\" src=\"./js/lib/fw/images/sort_0.gif\" />"
+ " "
+ dynamicGridObjs[gridNo].column[i].title
+ "</a>";
}
cell.style.width = dynamicGridObjs[gridNo].column[i].width;
} else if (i == dynamicGridObjs[gridNo].column.length - 1){
if(dynamicGridObjs[gridNo].rightHeaderAction >0){
var cell = row.insertCell(counter++);
cell.colSpan =dynamicGridObjs[gridNo].rightRowAction;
cell.innerHTML = dynamicGridObjs[gridNo].column[i].title + " " + dynamicGridObjs[gridNo].rightHeaderContent;
}else if(dynamicGridObjs[gridNo].rightRowAction >0){
var cell = row.insertCell(counter++);
cell.colSpan =dynamicGridObjs[gridNo].rightRowAction;
cell.width="5%";
cell.innerHTML = dynamicGridObjs[gridNo].column[i].title;
}
}
}
} catch (e) {
// alert("Create Header : "+e);
}
}
function createFooter(gridNo) {
try{
var tableName = dynamicGridObjs[gridNo].gridObj + "table";
var tableString = "<table border='0' cellspacing='0' cellpadding='0'><tr class='tablePageInfo' >"
+ "<td onclick=\"openSearchWindow('searchPanel"
+ gridNo
+ "')\" title=\"Search\"><img style=\"border: none; padding-left: 10px; padding-right: 10px;\" width=\"16px\" height=\"16px\" src=\"./js/lib/fw/images/search.png\" id=\"searchButton\" /></td>"
+ "<td><a href=\"javascript:reDrawGrid("
+ gridNo
+ ");\" title=\"Refresh\"> <img style=\"border: none;\" width=\"14px\" height=\"12px\" src=\"./js/lib/fw/images/refresh.png\" /></a></td>"
+ "<td style=\"color:#444444;\"> Display: </td>"
+ "<td><select title='Select number of rows to view in grid' id='selPageLength_"
+ gridNo
+ "' name='selPageLength_"
+ gridNo
+ "' style='width:60px' onchange='selectPageLength("
+ gridNo
+ ")'padding-left: 10px; ></select></td><td></td>";
if (dynamicGridObjs[gridNo].disableCount) {
tableString += "<td></td>";
} else {
tableString += "<td><a href=\"javascript:firstPage("
+ gridNo
+ ")\" title=\"First Page\"> <img style=\"border: none; padding-left: 10px;\" width=\"12px\" height=\"12px\" src=\"./js/lib/fw/images/x-left.png\" /></a></td>";
}
tableString += "<td> </td>"
+ "<td><a href=\"javascript:priPage("
+ gridNo
+ ")\" title=\"Previous\"> <img style=\"border: none;\" width=\"12px\" height=\"12px\" src=\"./js/lib/fw/images/left.png\" /></a></td>"
+ "<td style=\"color:#444444;\"> Page: </td>"
+ "<td ><input title='Enter Page' type='text' id='pageNo_" + gridNo
+ "' ";
if (dynamicGridObjs[gridNo].disableCount) {
tableString += " disabled='disabled' ";
tableString += "size='4' onkeypress='pageSwitch(event,"
+ gridNo
+ ")' style='width:40px;color: black;'/></td>";
} else {
tableString += "size='4' onkeypress='pageSwitch(event,"
+ gridNo
+ ")' style='width:40px;background-color: white;color: black;'/></td>";
}
tableString += "<td> </td>"
+ "<td><a href=\"javascript:nextPage("
+ gridNo
+ ")\" title=\"Next\"> <img style=\"border: none;\" width=\"12px\" height=\"12px\" src=\"./js/lib/fw/images/right.png\" /></a></td>"
+ "<td> </td>";
if (dynamicGridObjs[gridNo].disableCount) {
tableString += "<td></td>";
} else {
tableString += "<td><a href=\"javascript:lastPage("
+ gridNo
+ ")\" title=\"Last Page\"> <img style=\"border: none;\" width=\"12px\" height=\"12px\" src=\"./js/lib/fw/images/x-right.png\" /></a></td>";
}
tableString += "<td> </td>"
+ "<td width='100%' align=\"right\"><span id='pageInfo_" + gridNo
+ "' style='color: #999999; padding-right: 5px'></span></td>"
+"</tr></tbody></table><div id='lodingPanel_"+gridNo+"'></div>" ;
var row = document.getElementById(tableName).insertRow(
document.getElementById(tableName).rows.length);
row.className = "cellHeader";
var cell = row.insertCell(0);
var limit=dynamicGridObjs[gridNo].column.length;
var left =dynamicGridObjs[gridNo].rightRowAction;
var right =dynamicGridObjs[gridNo].leftRowAction;
if ((dynamicGridObjs[gridNo].leftHeaderAction >0 || left >0) && ( dynamicGridObjs[gridNo].rightHeaderAction >0 || right >0)){
cell.colSpan = (limit+ left + right)-2;
}else if (dynamicGridObjs[gridNo].leftHeaderAction >0 || left >0){
cell.colSpan = (limit+ left)-2;
}else if ( dynamicGridObjs[gridNo].rightHeaderAction >0 || right >0){
cell.colSpan = (limit+ right)-2;
}
else {
cell.colSpan = limit-2;
}
cell.innerHTML = tableString;
i = 10;
while (i <= 250) {
var itemOption = document.createElement('option');
itemOption.text = i;
itemOption.value = i;
if (dynamicGridObjs[gridNo].recordLength == i)
itemOption.selected = true;
document.getElementsByName("selPageLength_" + gridNo)[0].options.add(
itemOption, i);
if (i < 50)
i += 5;
else
i += 50;
}
var row = document.getElementById(tableName).insertRow(
document.getElementById(tableName).rows.length - 1);
row.setAttribute("id", "searchPanel" + gridNo);
var counter=0;
if(dynamicGridObjs[gridNo].leftRowAction >0 || dynamicGridObjs[gridNo].leftHeaderAction >0){
var cell = row.insertCell(counter++);
cell.style.width = dynamicGridObjs[gridNo].column[0].width;
cell.colSpan =dynamicGridObjs[gridNo].leftRowAction;
cell.innerHTML = "";
}
for (var j = 1; j < dynamicGridObjs[gridNo].column.length-1; j++) {
var cell = row.insertCell(counter++);
cell.style.width = dynamicGridObjs[gridNo].column[j].width;
if (dynamicGridObjs[gridNo].column[j].datatype != "Date" && dynamicGridObjs[gridNo].column[j].datatype != "image" ) {
cell.innerHTML = "<input type=\"text\" id =\"" + gridNo + "_" + j
+ "\" name=\"" + gridNo + "_" + j
+ "\" onkeypress=\"performFilter(event," + gridNo
+ ")\" style=\" width :100%\" />";
cell.className = "cellBorder";
} else {
cell.innerHTML = "<input type=\"text\" id =\"" + gridNo + "_" + j
+ "\" name=\"" + gridNo + "_" + j
+ "\" style=\"visibility:hidden;width:100%;\" />";
}
}
if (dynamicGridObjs[gridNo].rightRowAction >0 || dynamicGridObjs[gridNo].rightHeaderAction >0){
var cell = row.insertCell(counter++);
cell.style.width = dynamicGridObjs[gridNo].column[dynamicGridObjs[gridNo].column.length-1].width;
cell.colSpan =dynamicGridObjs[gridNo].rightRowAction;
cell.innerHTML = "";
}
openSearchWindow("searchPanel" + gridNo);
}
catch(e){
alert(e);
}
}
function loadData(genericlist, gridNo) {
try {
tableName = tableName = dynamicGridObjs[gridNo].gridObj + "table";
try {
while (document.getElementById(tableName).rows.length > 3)
document.getElementById(tableName).deleteRow(1);
} catch (e) {
//drawGrid();
}
var loopEnd = genericlist.list.length;
if (dynamicGridObjs[gridNo].disableCount
&& loopEnd > dynamicGridObjs[gridNo].recordLength) {
loopEnd--;
}
for (rowId = 0; rowId < loopEnd; rowId++) {
var rowData = genericlist.list[rowId];
var row = document.getElementById(tableName).insertRow(rowId + 1);
if (rowId % 2 == 0) {
row.className = "cellEvenRow";
} else {
row.className = "cellOddRow";
}
var cellCounter = 0;
/* conditional action display */
if (dynamicGridObjs[gridNo].leftRowAction > 0) {
for (var k = 0; k < dynamicGridObjs[gridNo].actionList.length; k++) {
var Action = dynamicGridObjs[gridNo].actionList[k];
if (Action.isHeader == false && Action.isActive == true && Action.direction == "L" ) {
var cell = row.insertCell(cellCounter++);
cell.className = "cellBorder";
// cell.width = "1%";
cell.style.textAlign="center";
if((Action.bindProperty=='')||(Action.bindProperty!='' && (""+rowData[Action.bindProperty])=="true")){
cell.innerHTML = "<img src=\""
+ Action.imagePath
+ "\" onClick=\""
+ setMethod(Action.functionName, rowData)
+ "\" title=\""
+ Action.actionName
+ "\" style=\"border: none;cursor :pointer;\" width=\"18px\" height=\"16px \" />";
}
else{
cell.innerHTML = "";
}
}
}
} else if (dynamicGridObjs[gridNo].leftHeaderAction > 0) {
var cell = row.insertCell(cellCounter++);
cell.className = "cellBorder";
cell.innerHTML = "";
}
/* conditional action display */
for (j = 1; j < dynamicGridObjs[gridNo].column.length - 1; j++) {
var attr = dynamicGridObjs[gridNo].column[j].attribute;
var attrTitle = dynamicGridObjs[gridNo].column[j].title;
if (attrTitle.search("mm:ss") > -1) {
rowData[attr] = changeToMins(rowData[attr]);
}
var cell = row.insertCell(cellCounter++);
cell.className = "cellBorder";
cell.style.width = dynamicGridObjs[gridNo].column[j].width;
if (dynamicGridObjs[gridNo].column[j].datatype == "double"
|| dynamicGridObjs[gridNo].column[j].datatype == "long"
|| dynamicGridObjs[gridNo].column[j].datatype == "int") {
cell.style.textAlign = "right";
rowData[attr] = rowData[attr];
}
if (attr == "speed") {
if (parseFloat(rowData[attr]) < 0.10) {
// cell.style.color = "black";
// cell.style.backgroundColor= "gray";
cell.style.fontWeight = "bold";
rowData[attr] = "<table border=0><tr><td style='backgroundColor:gray;width:16px'> </td><td style='width:100%' align='right'>"
+ rowData[attr] + "</td></tr></table>";
} else if (parseFloat(rowData[attr]) < 20.01) {
// cell.style.color = "#FFFFFF";
// cell.style.backgroundColor = "red";
cell.style.fontWeight = "bold";
rowData[attr] = "<table border=0 width=100%><tbody><tr><td style='background-color:red;width:16px'> </td><td style='width:100%' align='right'>"
+ rowData[attr] + "</td></tr></tbody></table>";
} else if (parseFloat(rowData[attr]) < 35.01) {
// cell.style.color = "black";
// cell.style.backgroundColor = "orange";
cell.style.fontWeight = "bold";
rowData[attr] = "<table border=0 width=100%><tbody><tr><td style='background-color:orange;width:16px'> </td><td style='width:100%' align='right'>"
+ rowData[attr] + "</td></tr></tbody></table>";
} else if (parseFloat(rowData[attr]) < 50.01) {
// cell.style.color = "black";
// cell.style.backgroundColor = "yellow";
cell.style.fontWeight = "bold";
rowData[attr] = "<table border=0 width=100%><tbody><tr><td style='background-color:yellow;width:16px'> </td><td style='width:100%' align='right'>"
+ rowData[attr] + "</td></tr></tbody></table>";
} else {
// cell.style.color = "#FFFFFF";
// cell.style.backgroundColor = "green";
cell.style.fontWeight = "bold";
rowData[attr] = "<table border=0 width=100%><tbody><tr><td style='background-color:green;width:16px'> </td><td></td><td style='width:100%' align='right'>"
+ rowData[attr] + "</td></tr></tbody></table>";
}
}
if (attr == "linkConfigurationId.direction") {
cell.style.textAlign = "center";
}
if (dynamicGridObjs[gridNo].column[j].datatype == "double"
|| dynamicGridObjs[gridNo].column[j].datatype == "long"
|| dynamicGridObjs[gridNo].column[j].datatype == "int") {
cell.innerHTML = rowData[attr];
}
cell.innerHTML = rowData[attr];
if (cell.innerHTML == ' undefined'
|| cell.innerHTML == 'undefined '
|| cell.innerHTML == 'undefined') {
cell.innerHTML = "";
}
}
/* conditional action display */
if (dynamicGridObjs[gridNo].rightRowAction != 0) {
for (var k = 0; k < dynamicGridObjs[gridNo].actionList.length; k++) {
var Action = dynamicGridObjs[gridNo].actionList[k];
if (Action.isHeader == false && Action.isActive == true && Action.direction == "R" ) {
var cell = row.insertCell(cellCounter++);
cell.className = "cellBorder";
cell.width = "1%";
cell.style.textAlign="center";
if((Action.bindProperty=='')||(Action.bindProperty!='' && (""+rowData[Action.bindProperty])=="true")){
cell.innerHTML = "<img src=\""
+ Action.imagePath
+ "\" onClick=\""
+ setMethod(Action.functionName, rowData)
+ "\" title=\""
+ Action.actionName
+ "\" style=\"border: none;cursor :pointer;\" width=\"18px\" height=\"16px \" />";
}else{
cell.innerHTML = "";
}
}
}
} else if (dynamicGridObjs[gridNo].rightHeaderAction > 0) {
var cell = row.insertCell(cellCounter++);
cell.className = "cellBorder";
cell.innerHTML = "";
}
/* conditional action display */
}
$("#" + tableName).colResizable({
disable : true
});
$("#" + tableName).colResizable({
liveDrag : true,
draggingClass : "dragging",
gripInnerHtml : "<div class='grip'></div>"
});
if (!dynamicGridObjs[gridNo].disableCount && initCount == true) {
loadCount(gridNo);
} else if (dynamicGridObjs[gridNo].disableCount && dynamicGridObjs[gridNo].reDraw == true) {
callNextGrid();
dynamicGridObjs[gridNo].reDraw = false;
}
// var
// row=document.getElementById(tableName).insertRow(document.getElementById(tableName).rows.length-1);
// row.setAttribute("id","searchPanel"+gridNo);
// for(j=0;j<dynamicGridObjs[gridNo].column.length+rowAction-1;j++){
// var cell= row.insertCell(j);
// cell.className="cellBorder";
// if(j<dynamicGridObjs[gridNo].column.length-1 &&
// dynamicGridObjs[gridNo].column[j].datatype!="Date")
// cell.innerHTML="<input type=\"text\" id =\""+gridNo+"_"+j+"\"
// name=\""+gridNo+"_"+j+"\"
// onkeypress=\"performFilter(event,"+gridNo+")\" />";
// else
// cell.innerHTML="<input type=\"text\" id =\""+gridNo+"_"+j+"\"
// name=\""+gridNo+"_"+j+"\" style=\"visibility:hidden;width:1px;\" />";
// }
// openSearchWindow("searchPanel"+gridNo);
if(document.getElementById('loadingImg')){
document.getElementById('loadingImg').style.visibility = "hidden";
}
} catch (e) {
// alert("Load Data :" + e);
}
}
function changeToMins(rowVal){
if(rowVal!='NaN' && rowVal!=undefined){
rowVal+='';
var str=rowVal.split(".");
if(str.length>1){
var ss="";
var val="";
if(str[1].length==1){
val=parseInt(str[1]+"0")*0.60;
ss=roundNumber(val,0)+'';
}else if(str[1].length==2){
val=parseInt(str[1])*0.60;
ss=roundNumber(val,0)+'';
}else{
val=str[1].substring(0,2);
val=parseInt(val)*0.60;
ss = roundNumber(val, 0)+'';
}
if(ss.length==1){
ss="0"+ss;
}else if(ss.length>2){
ss=ss.substring(0, 2);
}
return str[0]+":"+ss;
}else{
return str[0]+":"+"00";
}
}else{
return "0:00";
}
}
function setMethod(method, rowValue) {
if (rowValue == undefined)
return method;
var start = false;
attribute = "";
beforeAtt = 0;
afterAtt = 0;
attributes = new Array();
otherAttribute = new Array();
for (i = 0; i < method.length; i++) {
if (method.substring(i, i + 1) == "}") {
start = false;
attributes[attributes.length] = attribute;
afterAtt = i + 1;
}
if (start == true) {
attribute += method.substring(i, i + 1);
}
if (method.substring(i, i + 1) == "{") {
otherAttribute[otherAttribute.length] = method.substring(afterAtt,
i);
attribute = "";
start = true;
beforeAtt = i;
}
}
otherAttribute[otherAttribute.length] = method.substring(afterAtt,
method.length);
str = ""
for (i = 0; i < otherAttribute.length - 1; i++) {
str += otherAttribute[i];
if (i < attributes.length)
str += rowValue[attributes[i]];
}
str += otherAttribute[otherAttribute.length - 1];
return str;
// return method.substring(0,beforeAtt)+rowValue[attribute]+
// method.substring(afterAtt,method.length);
}
// function setMethod(method,rowValue){
// if(rowValue==undefined)
// return method;
// var start=false;
// attribute="";
// beforeAtt=0;
// afterAtt=0;
//
// for(i=0;i<method.length;i++){
// if(method.substring(i,i+1)=="}"){
// start=false;
// afterAtt=i+1;
// }
// if(start==true){
// attribute+=method.substring(i,i+1);
// }
// if(method.substring(i,i+1)=="{"){
// start=true;
// beforeAtt=i;
// }
// }
// return method.substring(0,beforeAtt)+rowValue[attribute]+
// method.substring(afterAtt,method.length);
//
// }
// ======================== get data for grid ===============================
function loadSearch(no) {
try {
document.getElementById("lodingPanel_" + no).innerHTML="<div id=\"processDiv_"+no+"\" title=\"Please Wait...\">"
+"<table border=\"0\">"
+"<tr>"
+"<td align=\"center\">"
+"<img src=\"js/lib/images/loading.gif\" width=\"25px\" align=\"middle\">"
+"</td>"
+"</tr>"
+"<tr>"
+"<td align=\"center\">"
+"<h3 id=\"msgDialog\" >"
+"<span id=\"processMsg\">"
+"<font color=\"#6255ED\">Loading Data .... Please Wait</font>"
+"</span>"
+"</h3>"
+"</td>"
+"</tr>"
+"</table>"
+"</div>";
$('#processDiv_'+no).dialog({
autoOpen : false,
width : 250,
height : 130,
resizable : false,
closeOnEscape : false,
modal : true,
open : function(event, ui) {
$(".ui-dialog-titlebar").hide();
},close : function(event, ui) {
$.event.remove(this);
$(".ui-dialog-titlebar").show();
}
});
if (dynamicGridObjs[no].loadingDialog) {
$('#processDiv_'+no).dialog('open');
}
search = jQuery.extend(true, {}, dynamicGridObjs[no].interSearch);
for (i = 0; i < dynamicGridObjs[no].filterOperation.length; i++) {
search.operation[search.operation.length] = dynamicGridObjs[no].filterOperation[i];
}
if(dynamicGridObjs[no].retainFilterSearch==true){
dynamicGridObjs[no].lastFilterOperation = dynamicGridObjs[no].filterOperation.slice();
dynamicGridObjs[no].lastPageStatus=dynamicGridObjs[no].currentPageNo;
}
currentPageNo = dynamicGridObjs[no].currentPageNo;
recordLength = dynamicGridObjs[no].recordLength;
totalRecords = dynamicGridObjs[no].totalRecords;
if (dynamicGridObjs[no].disableCount) {
addPaging(currentPageNo * recordLength, recordLength + 1);
} else {
addPaging(currentPageNo * recordLength, recordLength);
}
/* multi order by */
if(dynamicGridObjs[no].sortType==1){
if (dynamicGridObjs[no].orderByOperant == "") {
addOrderBy("id", false);
} else {
addOrderBy(dynamicGridObjs[no].orderByOperant,
dynamicGridObjs[no].assending);
setOrderImage(dynamicGridObjs[no].orderByOperant, no);
}
}else if(dynamicGridObjs[no].sortType==2){
for(var i=dynamicGridObjs[no].sortList.length-1;i>=0;i--){
addMultiOrder(dynamicGridObjs[no].sortList[i].operant,dynamicGridObjs[no].sortList[i].assending);
}
}
/* multi order by */
var getUrl = dynamicGridObjs[no].urlForGridData;
if(dynamicGridObjs[no].isPost){
$.post(getUrl,{search :decodeURI(createSearchJson()),userId: getCookie("userId"),m:Math.random()},function (data){returnDataFillGrid(data,no)});
}else{
getUrl +="?search="
+ createSearchJson() + "&userId=" + getCookie("userId") + "&m="
+ Math.random();
$.get(getUrl,function (data){returnDataFillGrid(data,no)});
}
} catch (e) {
alert("Load Search :" + e);
}
}
function returnDataFillGrid(data,no) {
genericlist = eval('(' + data + ')');
loadData(genericlist, no);
$('#processDiv_'+no).dialog('close').remove();
document.getElementById("pageNo_" + no).value = currentPageNo + 1;
if (dynamicGridObjs[no].disableCount) {
var rec = genericlist.list.length;
loadDummyCount(no, rec);
} else {
currentPageNo=dynamicGridObjs[no].currentPageNo;
document.getElementById("pageNo_" + no).value = currentPageNo + 1;
var rec = currentPageNo * recordLength;
if (genericlist.list.length > 0) {
if (totalRecords != undefined
&& (rec + recordLength) > totalRecords)
document.getElementById("pageInfo_"
+ no).innerHTML = " "
+ (rec + 1) + " to "
+ totalRecords + " out of "
+ totalRecords;
else if (totalRecords != undefined)
document.getElementById("pageInfo_"
+ no).innerHTML = " "
+ (rec + 1)
+ " to "
+ ((currentPageNo * recordLength) + recordLength)
+ " out of " + totalRecords;
}
}
}
function loadDummyCount(gridNo, rec) {
if (rec < dynamicGridObjs[gridNo].recordLength + 1) {
totalRecords = ((dynamicGridObjs[gridNo].currentPageNo + 1) * dynamicGridObjs[gridNo].recordLength);
totalPages = dynamicGridObjs[gridNo].currentPageNo;
} else {
totalRecords = 1 + ((dynamicGridObjs[gridNo].currentPageNo + 1) * dynamicGridObjs[gridNo].recordLength);
totalPages = dynamicGridObjs[gridNo].currentPageNo + 1;
}
dynamicGridObjs[gridNo].totalRecords = totalRecords;
dynamicGridObjs[gridNo].totalPages = totalPages;
}
function loadCount(no) {
try {
document.getElementById("pageNo_" + no).value = dynamicGridObjs[no].currentPageNo + 1;
search = jQuery.extend(true, {}, dynamicGridObjs[no].interSearch);
search.orderBy=new seOrderBy();
for (i = 0; i <dynamicGridObjs[no].filterOperation.length; i++)
search.operation[search.operation.length] = dynamicGridObjs[no].filterOperation[i];
search.count = true;
var getUrl = dynamicGridObjs[no].urlForGridData
if(dynamicGridObjs[no].isPost){
$.post(getUrl,{search :decodeURI(createSearchJson()),userId: getCookie("userId"),m:Math.random()},function(data) {returnDataForCount(data,no)});
}else{
getUrl +="?search="
+ createSearchJson() + "&userId=" + getCookie("userId") + "&m="
+ Math.random();
$.get(getUrl,function(data) {returnDataForCount(data,no)});
}
} catch (e) {
// alert("Load Count :"+e);
}
}
function returnDataForCount(data,no){
genericlist = eval('(' + data + ')');
if (genericlist.list.length > 0) {
totalRecords = parseInt(genericlist.list[0]);
dynamicGridObjs[no].totalRecords = genericlist.list[0];
} else {
totalRecords = 0;
dynamicGridObjs[no].totalRecords = 0;
}
dynamicGridObjs[no].totalPages = parseInt((totalRecords / recordLength) - 1);
if (totalRecords % recordLength > 0) {
dynamicGridObjs[no].totalPages++;
}
var rec = currentPageNo * recordLength;
if (totalRecords == 0) {
document.getElementById("pageNo_" + no).value = 1;
document.getElementById("pageInfo_" + no).innerHTML = " ";
} else if (totalRecords != undefined
&& (rec + recordLength) > totalRecords)
document.getElementById("pageInfo_" + no).innerHTML = " "
+ (rec + 1)
+ " to "
+ totalRecords
+ " out of " + totalRecords;
else if (totalRecords != undefined)
document.getElementById("pageInfo_" + no).innerHTML = " "
+ (rec + 1)
+ " to "
+ ((currentPageNo * recordLength) + recordLength)
+ " out of " + totalRecords;
initCount = false;
if (dynamicGridObjs[no].reDraw == true){
callNextGrid();
}
}
function reDrawGrid(gridNo) {
dynamicGridObjs[gridNo].filterOperation= new Array();
dynamicGridObjs[gridNo].currentPageNo = 0;
initCount = true;
for (j = 1; j < dynamicGridObjs[gridNo].column.length - 1; j++) {
if (j < dynamicGridObjs[gridNo].column.length - 1
&& dynamicGridObjs[gridNo].column[j].datatype != "Date") {
document.getElementById("" + gridNo + "_" + j).value = "";
}
}
reSetOrder(gridNo); // multi order by
addSearchFilterOperations("ne", "id", "0");
loadSearch(gridNo);
}
// ===================================================================================
// ==================== add serach parameter to request ======================
// ---------------------- used for grid only ---------------------------
function seInputOnlyProjection(gridNo, seInputTemp) {
var search = jQuery.extend(true, {}, seInputTemp);
try {
search.operation = new Array();
search.orOperation = new Array();
search.orAndOperation = new Array();
search.range = new Array();
search.orRange = new Array();
search.orderBy = new seOrderBy();
search.groupBy = "";
search.count = false;
search.multiOrderBy= new Array(); // multi order by
search.aggrigation = new Array();
search.paging = new sePaging();
} catch (e) {
// alert(e);
}
return search;
}
// ------------------------------------------------------------------------
// -------------------- for static for grid which initalize before grid creation
// ----------
function addSearchOperations(operator, operant, value, gridNo) {
try {
var operation = new seOperation();
operation.operator = operator;
operation.operant = operant;
operation.value = value;
dynamicGridObjs[gridNo].interSearch.operation[dynamicGridObjs[gridNo].interSearch.operation.length] = operation;
} catch (e) {
// alert("Search Operation : "+ e);
}
}
function addORSearchOperations(operator, operant, value, gridNo) {
try {
var operation = new seOperation();
operation.operator = operator;
operation.operant = operant;
operation.value = value;
dynamicGridObjs[gridNo].interSearch.orOperation[dynamicGridObjs[gridNo].interSearch.orOperation.length] = operation;
} catch (e) {
// alert("Search Operation : " + e);
}
}
function addOrAndSearchOperations(operator, operant, value, gridNo) {
try {
var operation = new seOperation();
operation.operator = operator;
operation.operant = operant;
operation.value = value;
dynamicGridObjs[gridNo].interSearch.orAndOperation[dynamicGridObjs[gridNo].interSearch.orAndOperation.length] = operation;
} catch (e) {
// alert("Search Operation : " + e);
}
}
function cerateRange(operant, start, end, gridNo) {
var range = new seRange();
range.operant = operant;
range.start = start;
range.end = end;
dynamicGridObjs[gridNo].interSearch.range[dynamicGridObjs[gridNo].interSearch.range.length] = range;
}
function createGridOrRange(operant, start, end, gridNo) {
var range = new seRange();
range.operant = operant;
range.start = start;
range.end = end;
dynamicGridObjs[gridNo].interSearch.orRange[dynamicGridObjs[gridNo].interSearch.orRange.length] = range;
}
function createGridAggrigation(name, property, gridNo) {
var aggri = new aggrigation();
aggri.functionName = name;
aggri.property = property;
dynamicGridObjs[gridNo].interSearch.aggrigation[dynamicGridObjs[gridNo].interSearch.aggrigation.length] = aggri;
}
// --------------------- for add when search filter perform after grid loaded
// -----------
function addSearchFilterOperations(operator, operant, value,gridNo) {
try {
var operation = new seOperation();
operation.operator = operator;
operation.operant = operant;
operation.value = value;
dynamicGridObjs[gridNo].filterOperation[dynamicGridObjs[gridNo].filterOperation.length] = operation;
} catch (e) {
// alert(e);
}
}
function addGridGroupBy(operant, gridNo) {
dynamicGridObjs[gridNo].interSearch.groupBy = operant;
}
// ================================================================================
// ================================
// called when enter pressed in filter textbox
// immediate added at top of navigation bar
// ====================================
function performFilter(e, gridNo) {
try {
var key = (typeof event != 'undefined') ? window.event.keyCode
: e.keyCode;
if (key == 13) {
dynamicGridObjs[gridNo].currentPageNo = 0;
dynamicGridObjs[gridNo].reDraw = false;
gridIndex = gridNo;
dynamicGridObjs[gridNo].filterOperation = new Array();
for (i = 1; i < dynamicGridObjs[gridNo].column.length - 1; i++) {
if (document.getElementById(gridNo + "_" + i).value != "") {
if (dynamicGridObjs[gridNo].column[i].datatype == "String")
addSearchFilterOperations("like",
dynamicGridObjs[gridNo].column[i].attribute,
document.getElementById(gridNo + "_" + i).value
+ "%",gridNo);
else
addSearchFilterOperations("eq",
dynamicGridObjs[gridNo].column[i].attribute,
document.getElementById(gridNo + "_" + i).value,gridNo);
}
// document.getElementById(gridNo+"_"+i).value = "";
}
initCount = true;
currentPageNo = 0;
openSearchWindow("searchPanel" + gridNo);
loadSearch(gridNo);
}
} catch (e) {
// alert(e);
}
}
//====================== for sorting ========================================================
function addDefaultMultiSorting(pSortOn,order,gridNo){
for(var i=0;i<dynamicGridObjs[gridNo].defaultMultiSorting.length;i++){
if(dynamicGridObjs[gridNo].defaultMultiSorting[i].operant== pSortOn){
return;
}
}
var newSortItem=new seOrderBy();
newSortItem.operant=pSortOn;
newSortItem.assending=order;
dynamicGridObjs[gridNo].defaultMultiSorting[dynamicGridObjs[gridNo].defaultMultiSorting.length]=newSortItem;
}
function setDefaultOrder(gridNo){
for(var i=0;i<dynamicGridObjs[gridNo].defaultMultiSorting.length;i++){
var idImg = gridNo + "_" + dynamicGridObjs[gridNo].defaultMultiSorting[i].operant+ "Img";
if(dynamicGridObjs[gridNo].defaultMultiSorting[i].assending == true){
document.getElementById(idImg).src = "./js/lib/fw/images/sort_2.gif";
document.getElementById(idImg).title = "Assending";
}else{
document.getElementById(idImg).src = "./js/lib/fw/images/sort_1.gif";
document.getElementById(idImg).title = "Desending";
}
dynamicGridObjs[gridNo].sortList[dynamicGridObjs[gridNo].sortList.length]=dynamicGridObjs[gridNo].defaultMultiSorting[i];
}
}
function reSetOrder(gridNo){
try {
if(dynamicGridObjs[gridNo].sortType== 0)
return;// true;
for (var i = 0; i < dynamicGridObjs[gridNo].column.length - 1; i++) {
if(dynamicGridObjs[gridNo].column[i].title=="Actions"){
continue;
}
var lIdImg = gridNo + "_" + dynamicGridObjs[gridNo].column[i].attribute+ "Img";
document.getElementById(lIdImg).src = "./js/lib/fw/images/sort_0.gif";
document.getElementById(lIdImg).title = "Sort";
}
dynamicGridObjs[gridNo].sortList= new Array();
setDefaultOrder(gridNo);
}catch(e){
// alert(e);
}
}
function sortOn(pSortOn, gridNo) {
try {
if(dynamicGridObjs[gridNo].sortType ==1){
orderByCol = pSortOn;
dynamicGridObjs[gridNo].orderByOperant = pSortOn;
initCount = true;
dynamicGridObjs[gridNo].currentPageNo = 0;
if (dynamicGridObjs[gridNo].orderByOperant == pSortOn) {
if (dynamicGridObjs[gridNo].assending == true) {
dynamicGridObjs[gridNo].assending = false;
orderByTF = false;
} else {
dynamicGridObjs[gridNo].assending = true;
orderByTF = true;
}
} else {
dynamicGridObjs[gridNo].orderByOperant = pSortOn;
dynamicGridObjs[gridNo].assending = true;
orderByTF = true;
}
}else if(dynamicGridObjs[gridNo].sortType ==2){
var idImg = gridNo + "_" + pSortOn + "Img";
for (var i=0;i<dynamicGridObjs[gridNo].sortList.length;i++){
if(dynamicGridObjs[gridNo].sortList[i].operant==pSortOn){
dynamicGridObjs[gridNo].sortList.splice(i,1);
}
}
if(document.getElementById(idImg).title == "Desending"){
document.getElementById(idImg).src = "./js/lib/fw/images/sort_0.gif";
document.getElementById(idImg).title = "Sort";
}else{
var newSortItem=new seOrderBy();
newSortItem.operant=pSortOn;
if(document.getElementById(idImg).title == "Sort"){
document.getElementById(idImg).src = "./js/lib/fw/images/sort_2.gif";
document.getElementById(idImg).title = "Assending";
newSortItem.assending=true;
}else{
document.getElementById(idImg).src = "./js/lib/fw/images/sort_1.gif";
document.getElementById(idImg).title = "Desending";
newSortItem.assending=false;
}
if(dynamicGridObjs[gridNo].sortList.length == 2) {
idImg = gridNo + "_" + dynamicGridObjs[gridNo].sortList[0].operant + "Img";
document.getElementById(idImg).src = "./js/lib/fw/images/sort_0.gif";
document.getElementById(idImg).title = "Sort";
dynamicGridObjs[gridNo].sortList.splice(0,1);
}
dynamicGridObjs[gridNo].sortList[dynamicGridObjs[gridNo].sortList.length]=newSortItem;
}
}
loadSearch(gridNo);
} catch (e) {
// alert(e);
}
}
function setOrderImage(operant, gridNo) {
for (i = 0; i < dynamicGridObjs[gridNo].column.length - 1; i++) {
if(dynamicGridObjs[gridNo].column[i].title=="Actions"){
continue;
}
var lIdImg = gridNo + "_" + dynamicGridObjs[gridNo].column[i].attribute+ "Img";
document.getElementById(lIdImg).src = "./js/lib/fw/images/sort_0.gif";
}
var idImg = gridNo + "_" + operant + "Img";
if (dynamicGridObjs[gridNo].assending == false) {
document.getElementById(idImg).src = "./js/lib/fw/images/sort_1.gif";
document.getElementById(idImg).title = "Desending";
} else {
document.getElementById(idImg).src = "./js/lib/fw/images/sort_2.gif";
document.getElementById(idImg).title = "Assending";
}
}
// ======================= paging =======================================================
function selectPageLength(id) {
initCount = true;
dynamicGridObjs[id].currentPageNo = 0;
dynamicGridObjs[id].recordLength = parseInt(document
.getElementById("selPageLength_" + id).value);
loadSearch(id);
}
function pageSwitch(e, id) {
if (e.keyCode == 13) {
dynamicGridObjs[id].currentPageNo = (parseInt(document
.getElementById("pageNo_" + id).value) * 1) - 1;
if (dynamicGridObjs[id].currentPageNo < 0) {
dynamicGridObjs[id].currentPageNo = 0;
}
if (dynamicGridObjs[id].currentPageNo > dynamicGridObjs[id].totalPages) {
dynamicGridObjs[id].currentPageNo = parseInt(dynamicGridObjs[id].totalPages);
}
loadSearch(id);
}
}
// =====================function for open search window ====================
function openSearchWindow(ids) {
try{
$("#" + ids).slideToggle("fast");
}catch(e){
// alert(e);
}
}
// ==================== function for navigation in grid ====================
function firstPage(id) {
if (dynamicGridObjs[id].currentPageNo > 0) {
dynamicGridObjs[id].currentPageNo = 0;
loadSearch(id);
}
}
function lastPage(id) {
if (dynamicGridObjs[id].currentPageNo != dynamicGridObjs[id].totalPages
&& dynamicGridObjs[id].totalRecords > (dynamicGridObjs[id].recordLength * (dynamicGridObjs[id].currentPageNo + 1))) {
dynamicGridObjs[id].currentPageNo = parseInt(dynamicGridObjs[id].totalPages);
loadSearch(id);
}
}
function priPage(id) {
if (dynamicGridObjs[id].currentPageNo > 0) {
dynamicGridObjs[id].currentPageNo--;
loadSearch(id);
}
}
function nextPage(id) {
if (dynamicGridObjs[id].currentPageNo < dynamicGridObjs[id].totalPages
&& dynamicGridObjs[id].totalRecords > (dynamicGridObjs[id].recordLength * (dynamicGridObjs[id].currentPageNo + 1))) {
dynamicGridObjs[id].currentPageNo++;
loadSearch(id);
}
}
// ===========================================================================
function addImageItem(isNew, attributeName, attributeValue, displayImage, url,gridNo) {
try {
if (isNew == true) {
dynamicGridObjs[gridNo].imageArray["" + attributeName] = new Array();
}
dynamicGridObjs[gridNo].imageArray["" + attributeName][""
+ attributeValue] = [ displayImage, url ];
} catch (e) {
// alert("Add Image error" + e);
}
}
function roundNumber(num, dec) {
var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
return result;
}