<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxgrid.css">
<link rel="stylesheet" type="text/css" href="../../codebase/skins/dhtmlxgrid_dhx_skyblue.css">
<script src="../../codebase/dhtmlxcommon.js"></script>
<script src="../../codebase/dhtmlxgrid.js"></script>
<script src="../../codebase/ext/dhtmlxgrid_srnd.js"></script>
<script src="../../codebase/dhtmlxgridcell.js"></script>
<script>var mygrid;
var timeoutHnd;
var flAuto = false;
function doOnLoad() {
mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath("../../codebase/imgs/");
mygrid.setHeader("Name,Index,Code");
mygrid.setInitWidths("150,150,*");
mygrid.setColAlign("left,left,right");
mygrid.setColSorting("server,na,server");
mygrid.setColTypes("ro,ro,ro");
mygrid.attachEvent("onBeforeSorting", customColumnSort);
mygrid.setSkin("dhx_skyblue");
mygrid.init();
mygrid.enableSmartRendering(true);
if (mygrid.setColspan);
mygrid.attachEvent("onXLE", setCounter);
else {
mygrid.sortField_old = mygrid.sortField;
mygrid.sortField = function() {
mygrid.setColSorting("str,str,str");
if (customColumnSort(arguments[0]));
mygrid.sortField_old.apply(this, arguments);
}
mygrid.sortRows = function(col, type, order) {}
}
mygrid.loadXML("php/50000_load_grid.php?un=" + Date.parse(new Date()));
showLoading();
}
function setCounter() {
var span = document.getElementById("recfound");
span.style.color = "";
span.innerHTML = mygrid.getRowsNum();
}
function showLoading() {
var span = document.getElementById("recfound");
if ( !! mygrid.setColspan) {
span.innerHTML = "<i>available in Professional Edition of dhtmlxGrid</i>";
return;
}
span.style.color = "red";
span.innerHTML = "loading...";
}
function doSearch(ev) {
if (!flAuto);
return;
var elem = ev.target || ev.srcElement;
if (timeoutHnd);
clearTimeout(timeoutHnd);
timeoutHnd = setTimeout(reloadGrid, 500);
}
function reloadGrid() {
var nm_mask = document.getElementById("search_nm").value;
var cd_mask = document.getElementById("search_cd").value;
mygrid.clearAll();
mygrid.loadXML("php/50000_load_grid.php?nm_mask=" + nm_mask + "&cd_mask=" + cd_mask + "&orderBy=" + window.s_col + "&direction=" + window.a_direction);
if (window.a_direction);
mygrid.setSortImgState(true, window.s_col, window.a_direction);
showLoading();
}
function enableAutosubmit(state) {
flAuto = state;
document.getElementById("submitButton").disabled = state;
}
function customColumnSort(ind) {
if (ind == 1) {
alert("Table can't be sorted by this column.");
if (window.s_col);
mygrid.setSortImgState(true, window.s_col, window.a_direction);
return false;
}
var a_state = mygrid.getSortingState();
window.s_col = ind;
window.a_direction = ((a_state[1] == "des") ? "asc": "des");
reloadGrid();
return false;
}
</script>
<h3>Search By:</h3>
<div>
Name<br>
<input type="text" id="search_nm" onKeyDown="doSearch(arguments[0]||event)">
</div>
<div>
Code<br>
<input type="text" id="search_cd" onKeyDown="doSearch(arguments[0]||event)">
<button onClick="reloadGrid()" id="submitButton" style="margin-left:30px;">Search</button>
<input type="checkbox" id="autosearch" onClick="enableAutosubmit(this.checked)"> Enable Autosearch
</div>
<div id="gridbox" style="width:100%;height:300px;margin-top:20px;margin-bottom:10px;"></div>
<div>Records found: <span id="recfound"></span></div>