// --------------------------------------------------------------------------------------------------------------------------
// Support script for Extended API demonstration
// --------------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------------
// Members in red are JavaScript keywords
// Members in blue are TreeGrid functions and properties, contain link to documentation
// Members in bold are global functions and variables in this script
// Strings are "pink", numbers are blue
// --------------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------------
var IDisable, IStyle, DLog; // Pointers to html controls
var FRow; // Actual focused row for update
var Styles = [ // Style settings
"Style='G' Grid = 'Grid.gif' Toolbar='Toolbar.gif' Height = '17' Line = '21' Tree = '26' Panel = '13' Sort = '14' Filter = '17' Row = '17'",
"Style='GL' Grid = 'GridLight.gif' Toolbar='ToolbarLight.gif' Height = '17' Line = '21' Tree = '26' Panel = '13' Sort = '14' Filter = '17' Row = '17'",
"Style='GB' Grid = 'GridBigger.gif' Toolbar='Toolbar.gif' Height = '21' Line = '21' Tree = '26' Panel = '18' Sort = '14' Filter = '17' Row = '17'",
"Style='GG' Grid = 'GridGame.gif' Toolbar='Toolbar.gif' Height = '17' Line = '21' Tree = '26' Panel = '13' Sort = '14' Filter = '17' Row = '17'"
];
// --------------------------------------------------------------------------------------------------------------------------
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// --------------------------------------------------------------------------------------------------------------------------
// Creates grid from JavaScript
function Start(){
// --- Prepares and clears controls on pages ---
DLog = GetElem("LOG");
IStyle = GetElem("IStyle");
IDisable = GetElem("IDisable");
DLog.value = "";
IDisable.checked = false;
IStyle.checked = false;
GetElem("IColor").value = "002";
GetElem("SData").selectedIndex = 0;
GetElem("SStyle").selectedIndex = 0;
// --- creates grid ---
var D = new TDataIO(); // new object for communication
= "../Data/CalcAPIDef.xml";
D.Data.Url = "../Data/CalcAPIData.xml";
Resize(); // User function to resize main tag to resize it to whole window
TreeGrid(D,"GRID"); // Creates new grid, this grid will now be accessed from Grids[0] property
// Loads data chosen from the first combo
var idx = GetElem("SData").selectedIndex; // The first combo, contains selected data
"FirstData.xml","AjaxData.xml","TableData.xml","BooksData.xml","AddPageData.xml",
"../AspNetCS/PagingDLL/FileData.xml",
"Features1 Sorting.xml","Features2 Filters.xml","Features3
Grouping.xml","Features4 Searching.xml",
"Calc1 Columns.xml","Calc2 Rows.xml","Calc3
Order.xml","Calc4
Tree.xml","Calc5 Tree
order.xml",
D.Data.Url = "../../Tutorials/"+Data[idx];
D.Layout.Url = "../Data/"+Def[idx];
D.Data.Url = "../Data/"+Data[idx];
else D.Page.Url = null; // standard case
else D.Layout.Bonus=null; // standard case
var sidx = GetElem("SStyle").selectedIndex;
G.Reload(); // Reloads new data to grid
FRow = null; // Nulls FRow - no focused row in grid
// Called when window is resized to set extents of the grid to maximize its area
var h = S[1] - 270 - D.parentNode.offsetTop;;
if(h<R.offsetHeight) h = R.offsetHeight;
// Helper function, logs string to LOG DIV
function Log(str,ln,color,size){
var D = document.createElement(ln?"DIV":"SPAN");
D.innerHTML = str+(ln?"":"; ");
if(color) D.style.color = color;
if(size) D.style.fontSize = size;
// Helper function, escapes the string for using in XML/HTML (to display in log)
if(str.length>50) str = str.slice(0,50)+" ... ";
return str.replace(/&/g,"&").replace(/</g,"<");
Grids.OnGetColor = function(G,row,col,r,g,b,type){
if(IStyle.checked) Log("OnGetColor("+row.id+","+col+","+r+","+g+","+b+","+type+")",0,"#CAC");
Grids.OnGetDefaultColor = function(G,row,col,rgb){
if(IStyle.checked) Log("OnGetDefaultColor("+row.id+","+col+","+rgb+")",0,"#CAC");
}
Grids.OnGetClass = function(G,row,col,cls){
if(IStyle.checked) Log("OnGetClass("+row.id+","+col+","+cls+")",0,"#ACC");
if(G.id.slice(0,4)=="List") return ListGetClass(G,row,col,cls);
Grids.OnGetType = function(G,row,col,type){
if(IStyle.checked) Log("OnGetType("+row.id+","+col+","+type+")",0,"#CCA");
Grids.OnGetFormat = function(G,row,col,format,edit){
if(IStyle.checked) Log("OnGetFormat("+row.id+","+col+","+format+","+edit+")",0,"#CAA");
Grids.OnGetEnum = function(G,row,col,enuma){
if(IStyle.checked) Log("OnGetEnum("+row.id+","+col+","+enuma.join("|")+")",0,"#ACA");
if(G.id=="List3") return List3GetEnum(G,row,col,enuma); // Support function for particular example