|
function SDX_Navigator(_RootObject)
{
this.RootObject = _RootObject ;
this.GetPagingPanelHTMLID = GetPagingPanelHTMLID
this.GetSearchPanelHTMLID = GetSearchPanelHTMLID
this.SearchTextBoxHTMLID="SDXNavigator_SearcTextBox_" + this.RootObject.Name;
this.StatusBarHTMLID="SDXNavigator_StatusBar_" + this.RootObject.Name;
this.Visible=true;
this.Table = null ;
this.FilteredRows = new Array();
this.SearchValue="";
this.SearchColumn=-1;
this.PageIndex=1;
this.SortColumnIndex = null;
this.SortRotation = null;
this.RowLimit=this.RootObject.RowLimit;
this.ChangePageIndex=ChangePageIndex;
this.ChangeRowLimit=ChangeRowLimit;
this.SetStatusToNormal = SetStatusToNormal;
this.SetStatusToUpdating = SetStatusToUpdating;
this.SetStatusToDone = SetStatusToDone;
this.SetStatusToFailed = SetStatusToFailed;
this.Search=Search;
this.Sort = Sort;
this.reverseSort = reverseSort;
this.verseSort = verseSort;
this.GetEvalObjectString = GetEvalObjectString ;
this.RePaint = RePaint
this.GetPagingPanelHTMLOutPut = GetPagingPanelHTMLOutPut;
this.GetSearchPanelHTMLOutPut = GetSearchPanelHTMLOutPut;
this.HTMLOutPut=HTMLOutPut;
function GetEvalObjectString()
{
return this.Table.GetEvalObjectString() + ".Navigator" ;
}
function GetPagingPanelHTMLID()
{
return this.Table.HTMLID + "_Navigator_PagingPanel"
}
function GetSearchPanelHTMLID()
{
return this.Table.HTMLID + "_Navigator_SearchPanel"
}
function ChangeRowLimit(nRowCount)
{
this.RowLimit=nRowCount;
this.Table.RePaint()
}
function Sort(nColumnIndex,bNormal,bNoRePaint)
{
if(this.SortColumnIndex != nColumnIndex)
this.SortRotation = null;
this.SortColumnIndex = nColumnIndex;
if(bNormal == undefined)
{
if(this.SortRotation == 0)
{
this.SortRotation = 1;
}
else
{
this.SortRotation = 0;
}
}
else if(bNormal)
{
this.SortRotation = 0;
}
else
{
this.SortRotation = 1;
}
var cleanedFilteredRows = new Array();
for(var i=0;i<this.FilteredRows.length;i++)
{
if(this.RootObject.Datas.CurrentDatas[this.FilteredRows[i].DataKeyID]!=null)
cleanedFilteredRows[cleanedFilteredRows.length] = this.FilteredRows[i];
}
this.FilteredRows = cleanedFilteredRows;
if( this.SortRotation == 1)
{
this.FilteredRows.sort(this.reverseSort)
}
else
{
this.FilteredRows.sort(this.verseSort)
}
if(!bNoRePaint)
{
this.Table.RePaint();
}
}
function reverseSort(a,b)
{
var rootObject = a.RootObject ;
var nColumnIndex = a.DataTable.Navigator.SortColumnIndex;
var column = rootObject.Columns.Columns[nColumnIndex];
var data1 = column.Field.GetDisplayHTML( rootObject.Datas.CurrentDatas[a.DataKeyID].Data[column.ID]).toString() ;
var data2 = column.Field.GetDisplayHTML( rootObject.Datas.CurrentDatas[b.DataKeyID].Data[column.ID]).toString() ;
if(data1 > data2)
return -1
if(data1 < data2)
return 1
return 0
}
function verseSort(a,b)
{
var rootObject = a.RootObject ;
var nColumnIndex = a.DataTable.Navigator.SortColumnIndex;
var column = rootObject.Columns.Columns[nColumnIndex];
var data1 = column.Field.GetDisplayHTML( rootObject.Datas.CurrentDatas[a.DataKeyID].Data[column.ID]).toString() ;
var data2 = column.Field.GetDisplayHTML( rootObject.Datas.CurrentDatas[b.DataKeyID].Data[column.ID]).toString() ;
if(data1 > data2)
return 1
if(data1 < data2)
return -1
return 0
}
function Search(sSearchValue,bNotKeyUp)
{
this.PageIndex=1;
this.SearchValue=sSearchValue;
sSearchValue=sSearchValue.toLowerCase()
if(!bNotKeyUp)
{
var nKeyCode=(navigator.appName=="Microsoft Internet Explorer"?event.keyCode:e.keyCode)
if(nKeyCode!=13)
return
}
if(this.SearchValue=="")
{
var aNewRows=new Array();
for(var nX in this.Table.Rows)
{
aNewRows[aNewRows.length] = this.Table.Rows[nX] ;
}
this.FilteredRows=aNewRows;
if(this.SortColumnIndex!="" && this.SortColumnIndex!=null)
this.Sort(this.SortColumnIndex,this.SortRotation,true);
this.Table.RePaint();
return;
}
var aNewRows=new Array();
if(this.SearchColumn==-1)
{
for(var nX in this.Table.Rows)
{
var columns = this.RootObject.Columns.GetColumnsDisplayInTable() ;
for(var nY in columns)
{
var data = columns[nY].Field.GetDisplayHTML( this.RootObject.Datas.CurrentDatas[this.Table.Rows[nX].DataKeyID].Data[columns[nY].ID]).toString() ;
if(data.toLowerCase().indexOf(sSearchValue)>-1)
{
aNewRows[aNewRows.length] = this.Table.Rows[nX] ;
break;
}
}
}
}
else
{
for(var nX in this.Table.Rows)
{
if(this.Table.Rows[nX].GetRowView().Cells.GetCell(this.SearchColumn).HTMLOutPut().toString().toLowerCase().indexOf(sSearchValue)>-1)
{
aNewRows[aNewRows.length] = this.Table.Rows[nX]
}
}
}
this.FilteredRows=aNewRows;
if(this.SortColumnIndex!="" && this.SortColumnIndex!=null)
this.Sort(this.SortColumnIndex,this.SortRotation,true);
this.Table.RePaint();
}
function ChangePageIndex(nIndex)
{
if(isNaN(nIndex))
{
alert("Wrong entry");
return;
}
var nPageCount=Math.ceil(this.FilteredRows.length/this.RowLimit);
if(nIndex>nPageCount)
{
alert("Your selected page index is greater than the page count");
return;
}
if(nIndex<1)
{
alert("Your selected page index must be greater than 0");
return;
}
this.PageIndex = nIndex ;
this.Table.RePaint() ;
}
function RePaint()
{
document.getElementById(this.GetPagingPanelHTMLID()).innerHTML=this.GetPagingPanelHTMLOutPut();
document.getElementById(this.GetSearchPanelHTMLID()).innerHTML=this.GetSearchPanelHTMLOutPut();
}
function SetStatusToNormal()
{
document.getElementById(this.StatusBarHTMLID).innerHTML=" ";
}
function SetStatusToUpdating()
{
document.getElementById(this.StatusBarHTMLID).innerHTML="<img valign='absmiddle' src=\"" + this.RootObject.ResourcePath + "images/updating.gif\"> Updating Changes... ";
}
function SetStatusToDone()
{
document.getElementById(this.StatusBarHTMLID).innerHTML="<img valign='absmiddle' src=\"" + this.RootObject.ResourcePath + "images/completed.jpg\"> Saved succesfully. ";
}
function SetStatusToFailed()
{
document.getElementById(this.StatusBarHTMLID).innerHTML="<img valign='absmiddle' src=\"" + this.RootObject.ResourcePath + "images/failed.jpg\"> Failed. ";
}
function GetPagingPanelHTMLOutPut()
{
var nPageCount=Math.ceil(this.FilteredRows.length/this.RowLimit);
var sHTMLOutPut="<table " + this.RootObject.Styles.GetStyleHTML(this.RootObject.Styles.NavigatorStyle) + " width=\"100%\" >" +
" <tr>" +
" <td width='10' " + this.RootObject.Styles.GetStyleHTML(this.RootObject.Styles.PagerStyle) + "> </td>" +
" <td width='10' " + this.RootObject.Styles.GetStyleHTML(this.RootObject.Styles.PagerStyle) + " nowrap id='" + this.StatusBarHTMLID + "'> </td>"
if(this.RootObject.AllowAdd==true || this.RootObject.AllowDelete==true || this.RootObject.AllowEdit==true)
{
sHTMLOutPut+=" <td width='25' " + this.RootObject.Styles.GetStyleHTML(this.RootObject.Styles.PagerStyle) + ">" +
" <img height=15 width=15 src=\"" + this.RootObject.ResourcePath +
"images/save.jpg\" align=\"absMiddle\" style='cursor:pointer' onclick=\"" +
this.GetEvalObjectString() + ".RootObject.GeneralFunctions.SendData(" + this.GetEvalObjectString() + ".RootObject)" + "\" /> " +
" </td>"
}
sHTMLOutPut+=(this.RootObject.AllowAdd==true?" <td width='25' " + this.RootObject.Styles.GetStyleHTML(this.RootObject.Styles.PagerStyle) + "><a href=\"javascript:" + this.Table.GetEvalObjectString() + ".AddNewRow()\"><img height=15 width=15 border=0 src=\"" + this.RootObject.ResourcePath + "images/insert.jpg\"></a></td>":"") +
(this.RootObject.AllowDelete==true?" <td width='25' " + this.RootObject.Styles.GetStyleHTML(this.RootObject.Styles.PagerStyle) + "><a href=\"javascript:" + this.RootObject.GetEvalObjectString() + ".Rows.DeleteSelectedRows()\"><img height=15 width=15 border=0 src=\"" + this.RootObject.ResourcePath + "images/delete.jpg\"></a></td>":"") +
(this.RootObject.AllowSearch==true?" <td width='90%' align=\"right\" " + this.RootObject.Styles.GetStyleHTML(this.RootObject.Styles.PagerStyle) + " valign='bottom'>" +
"<a href=\"javascript:" + this.GetEvalObjectString() + ".ChangePageIndex(1)" + "\"><img valign='bottom' height=15 width=15 border=0 src=\"" + this.RootObject.ResourcePath + "images/first.jpg\"></a> </td>" +
"<td " + this.RootObject.Styles.GetStyleHTML(this.RootObject.Styles.PagerStyle) + " valign='bottom'><a href=\"javascript:" + this.GetEvalObjectString() + ".ChangePageIndex(" + (this.PageIndex-1) + ")" + "\"><img height=15 width=15 border=0 src=\"" + this.RootObject.ResourcePath + "images/previous.jpg\"></a> </td>" +
"<td " + this.RootObject.Styles.GetStyleHTML(this.RootObject.Styles.PagerStyle) + " valign='bottom'> <input class=\"spTxtboxs\" id=\"sss\" size=\"2\" style=\"width:20\" onchange=\"" + this.GetEvalObjectString() + ".ChangePageIndex(this.value)\" value=\"" + this.PageIndex + "\" /> / " +
nPageCount + " </td>" +
"<td " + this.RootObject.Styles.GetStyleHTML(this.RootObject.Styles.PagerStyle) + " valign='bottom'><a href=\"javascript:" + this.GetEvalObjectString() + ".ChangePageIndex(" + (this.PageIndex+1) + ")" + "\"><img height=15 width=15 border=0 src=\"" + this.RootObject.ResourcePath + "images/next.jpg\"></a> </td>" +
"<td " + this.RootObject.Styles.GetStyleHTML(this.RootObject.Styles.PagerStyle) + " valign='bottom'><a href=\"javascript:" + this.GetEvalObjectString() + ".ChangePageIndex(" + nPageCount + ")" + "\"><img height=15 width=15 border=0 src=\"" + this.RootObject.ResourcePath + "images/last.jpg\"></a> " +
"</td>":"") +
" </tr>" +
"</table>"
return sHTMLOutPut;
}
function GetSearchPanelHTMLOutPut()
{
while(nX<this.RowLimit*(this.PageIndex));
sFieldsOption="<option value=-1>All fields</option>"
var columns = this.RootObject.Columns.GetColumnsDisplayInTable() ;
for(var nX in columns)
{
sFieldsOption+="<option value=" + columns[nX].Key + " " + (this.SearchColumn==columns[nX].Key?"Selected":"") + ">" + columns[nX].Header + "</option>"
}
var sHTMLOutPut="<table " + this.RootObject.Styles.GetStyleHTML(this.RootObject.Styles.NavigatorStyle) + " width=\"100%\" >"
if(this.RootObject.AllowSearch==true )
{
sHTMLOutPut+=" <tr>" +
" <td width='100%' align=\"left\" " + this.RootObject.Styles.GetStyleHTML(this.RootObject.Styles.SearchStyle) + "> " +
" <select class='Selectbox' onchange=\"" + this.GetEvalObjectString() + ".SearchColumn=this.options[this.options.selectedIndex].value" + "\">" +
sFieldsOption +
" </select>" +
" <input class=\"spTxtboxs\" value=\"" + this.SearchValue + "\" onchange=\"" + this.GetEvalObjectString() + ".Search(this.value)" + "\" ID=\"" + this.SearchTextBoxHTMLID + "\" />" +
" <img height=15 width=15 src=\"" + this.RootObject.ResourcePath + "images/sp_icoSearch.gif\" align=\"absMiddle\" style='cursor:pointer' onclick=\"" + this.GetEvalObjectString() + ".Search(document.getElementById('" + this.SearchTextBoxHTMLID + "').value,true)" + "\" /> " +
" </td>"
}
sHTMLOutPut+="</table>"
return sHTMLOutPut;
}
function HTMLOutPut()
{
var nPageCount=Math.ceil(this.FilteredRows.length/this.RowLimit);
while(nX<this.RowLimit*(this.PageIndex));
sFieldsOption="<option value=-1>All fields</option>"
var columns = this.RootObject.Columns.GetColumnsDisplayInTable() ;
for(var nX in columns)
{
sFieldsOption+="<option value=" + columns[nX].Key + " " + (this.SearchColumn==columns[nX].Key?"Selected":"") + ">" + columns[nX].Header + "</option>"
}
var sHTMLOutPut="<table " + this.RootObject.Styles.GetStyleHTML(this.RootObject.Styles.NavigatorStyle) + " width=\"100%\" >" +
" <tr>" +
" <td align=\"center\" colspan=2 " + this.RootObject.Styles.GetStyleHTML(this.RootObject.Styles.SearchStyle) + ">" +
" <img height=15 width=15 src=\"" + this.RootObject.ResourcePath + "images/sp_icoSearch.gif\" align=\"absMiddle\" style='cursor:pointer' onclick=\"" + this.GetEvalObjectString() + ".Search(document.getElementById('" + this.SearchTextBoxHTMLID + "').value,true)" + "\" /> " +
" <input class=\"spTxtboxs\" value=\"" + this.SearchValue + "\" onchange=\"" + this.GetEvalObjectString() + ".Search(this.value)" + "\" ID=\"" + this.SearchTextBoxHTMLID + "\" />" +
" <select class='Selectbox' onchange=\"" + this.GetEvalObjectString() + ".SearchColumn=this.options[this.options.selectedIndex].value" + "\">" +
sFieldsOption +
" </select>" +
" </td>" +
" </tr>" +
" <tr>" +
" <td width=\"50%\" " + this.RootObject.Styles.GetStyleHTML(this.RootObject.Styles.PagerStyle) + ">" +
" <img height=15 width=15 src=\"" + this.RootObject.ResourcePath + "images/save.jpg\" align=\"absMiddle\" style='cursor:pointer' onclick=\"" + this.GetEvalObjectString() + ".RootObject.GeneralFunctions.SendData(" + this.GetEvalObjectString() + ".RootObject)" + "\" /> " +
" <select class='Selectbox' onchange=\"" + this.GetEvalObjectString() + ".ChangeRowLimit(this.options[this.options.selectedIndex].value)" + "\">" +
" <option value=5 " + (this.RowLimit==5?"Selected":"") + ">5</option>" +
" <option value=10 " + (this.RowLimit==10?"Selected":"") + ">10</option>" +
" <option value=15 " + (this.RowLimit==15?"Selected":"") + ">15</option>" +
" <option value=20 " + (this.RowLimit==20?"Selected":"") + ">20</option>" +
" <option value=25 " + (this.RowLimit==25?"Selected":"") + ">25</option>" +
" <option value=30 " + (this.RowLimit==30?"Selected":"") + ">30</option>" +
" </select>" +
" </td>" +
" <td align=\"right\" " + this.RootObject.Styles.GetStyleHTML(this.RootObject.Styles.PagerStyle) + ">" +
(this.PageIndex>1?"<span onclick=\"" + this.GetEvalObjectString() + ".ChangePageIndex(1)" + "\"><< |</span>":"<span><< |</span>") +
(this.PageIndex>1?"<span onclick=\"" + this.GetEvalObjectString() + ".ChangePageIndex(" + (this.PageIndex-1) + ")" + "\"> Previous </span>":"<span> Previous </span>") +
" <input class=\"spTxtboxs\" id=\"sss\" size=\"2\" style=\"width:20\" onchange=\"" + this.GetEvalObjectString() + ".ChangePageIndex(this.value)\" value=\"" + this.PageIndex + "\" /> / " +
nPageCount + " " +
(this.PageIndex<nPageCount?"<span onclick=\"" + this.GetEvalObjectString() + ".ChangePageIndex(" + (this.PageIndex+1) + ")" + "\"> Next</span>":"<span> Next</span>") +
(this.PageIndex<nPageCount?"<span onclick=\"" + this.GetEvalObjectString() + ".ChangePageIndex(" + nPageCount + ")" + "\"> |":"<span> |") +
" >></span>" +
" </td>" +
" </tr>" +
"</table>"
return sHTMLOutPut;
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.