CLICK HERE TO BUY IT TODAY! OR GET IT FREE VIA TRIALPAY  

PHP Demo Application - Source Code

/Framework/Model/Vendor/FlexiGrid/flexigrid.js



/*
 * Flexigrid for jQuery - New Wave Grid
 *
 * Copyright (c) 2008 Paulo P. Marinas (webplicity.net/flexigrid)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * $Date: 2008-07-14 00:09:43 +0800 (Tue, 14 Jul 2008) $
 */
(function($){
	    $.addFlex = function(t,p)
	    {
		        if (t.grid) return false;
		 //return if already exist
		        function addSortColumn(thsort) {
			            var column = $(th).attr('abbr');
			            $('div',th).removeClass('sasc');
			            $('div',th).removeClass('sdesc');
			            if (isSortColumnAdded(columnsort)) {
				                sort[column] = 'asc';
				                $(th).addClass('sorted');
				                $('div',th).addClass('sasc');
				} else {
				                if (sort[column] == 'asc') {
					                    sort[column] = 'desc';
					                    $(th).addClass('sorted');
					                    $('div',th).addClass('sdesc');
					} else {
					                    delete sort[column];
					                    $(th).removeClass('sorted');
					 // .siblings().removeClass('sorted')
					}
				}            
			            return sort;
			}
		        function isSortColumnAdded(columnsort) {
			            return ((typeof sort[column]) == 'undefined');
			}
		        function implode(parameters)    {
			            var value '';
			            var found false;
			            for (var row in parameters.sort) {
				                if (value != '') {
					                    value += ',';
					}
				                value += row ':' parameters.sort[row];
				                found true;
				}
			            // Hide Deselect button if no columns selected
			            if (found) {
				                $('#btnClearSort_flex_1').css('display''block');
				} else {
				                $('#btnClearSort_flex_1').css('display''none');
				}            
			            return value;
			}
		        function getSortDirection(columnsort) {
			            for (var col in sort) {
				                if (col == column) {
					                    return sort[col];
					                    break;
					}
				}
			            return false;
			}
		        // apply default properties
		        = $.extend({
			             uniqueIndex0// unique identifier
			             type0// 1 = Editor Grid, 2 = Selection Grid
			             dataObject''// Data Object name
			             baseUrl''// Path to Controller Entry Point             
			             displayColumn''// Column used to return in selction grid.  
			             returnId''// Field to return selected ID value to
			             returnDisplay''// Field to return selected Display value to             
			             imageViewer'request/image'// URL to script to display image files
			             fileRequest'request/file'// URL to script to fet files
			             iconRequest'request/icon'// URL to script to get image icon             
			             exportRequest'request/export'// URL to script to export data
			             formRequest'request/form'// URL to script to load form
			             url'request/grid_data'//ajax url
			             defaultImage''// Image to display when none supplied or can't be found
			             height'auto'//default height
			             width'90%'//default width
			             stripedtrue//apply odd even stripes
			             novstripefalse,
			             minwidth30//min width of columns
			             minheight80//min height of columns
			             resizablefalse//resizable table             
			             method'POST'// data sending method
			             dataType'json'// type of data loaded
			             errormsglanguage.GRID_ERRORMSG,
			             usepagertrue//
			             nowraptrue//
			             page1//current page
			             total1//total pages
			             useRptrue//use the results per page select box
			             rp15// results per page
			             rpOptions: [10,15,20,25,40],
			             titlefalse,
			             pagestatlanguage.GRID_STATS,
			             pagetextlanguage.GRID_PAGE,
			             outoflanguage.GRID_OF,
			             findtextlanguage.GRID_FIND,
			             procmsglanguage.GRID_PROCESSING,
			             query'',
			             qtype'',
			             nomsglanguage.GRID_NOITEMS,
			             minColToggle1//minimum allowed column to be hidden
			             showToggleBtnfalse//show or hide column toggle popup
			             hideOnSubmittrue,
			             autoloadtrue,
			             blockOpacity0.5,
			             name'',
			             onDragColfalse,
			             onToggleColfalse,
			             onChangeSortfalse,
			             onSuccessfalse,
			             onErrorfalse,
			             onSubmitfalse// using a custom populate function
			             onClickfalse,
			             onDblClickfalse 
			}, p);
		        $(t)
		        .show() //show if hidden
		        .attr({cellPadding0cellSpacing0border0})  //remove padding and spacing
		        .removeAttr('width'//remove width properties    
		        ;
		        //if (p.width.indexOf('%')) {
			            //var pc = p.width.replace('%', '');
			            //var pcWidth = ($(window).width() / 100);
			            //var newWidth = Math.round(pcWidth * pc);
			            //p.width = newWidth;
			        //}
		        //create grid class
		        var = {
			            hset {},
			            rePosDrag: function () {
				            var cdleft this.hDiv.scrollLeft;
				            if (this.hDiv.scrollLeft>0cdleft -= Math.floor(p.cgwidth/2);
				            $(g.cDrag).css({top:g.hDiv.offsetTop+1});
				            var cdpad this.cdpad;
				            $('div',g.cDrag).hide();
				            $('thead tr:first th:visible',this.hDiv).each
				                (
				                 function ()
				                    {
					                    var = $('thead tr:first th:visible',g.hDiv).index(this);
					                    var cdpos parseInt($('div',this).width());
					                    var ppos cdpos;
					                    if (cdleft==0) 
					                            cdleft -= Math.floor(p.cgwidth/2);
					                    cdpos cdpos cdleft cdpad;
					                    $('div:eq('+n+')',g.cDrag).css({'left':cdpos+'px'}).show();
					                    cdleft cdpos;
					                    }
				                );
				            },
			            fixHeight: function (newH) {
				                    newH false;
				                    if (!newHnewH = $(g.bDiv).height();
				                    var hdHeight = $(this.hDiv).height();
				                    $('div',this.cDrag).each(
				                        function ()
				                            {
					                                $(this).height(newH+hdHeight);
					                            }
				                    );
				                    var nd parseInt($(g.nDiv).height());
				                    if (nd>newH)
				                        $(g.nDiv).height(newH).width(200);
				                    else
				                        $(g.nDiv).height('auto').width('auto');
				                    $(g.block).css({height:newH,marginBottom:(newH * -1)});
				                    var hrH g.bDiv.offsetTop newH;
				                    if (p.height != 'auto' && p.resizablehrH g.vDiv.offsetTop;
				                    hrH 24;
				                    $(g.rDiv).css({heighthrH});
				            },
			            dragStart: function (dragtype,e,obj) {
				//default drag function start
				                if (dragtype=='colresize'//column resize
				                    {
					                        $(g.nDiv).hide();
					$(g.nBtn).hide();
					                        var = $('div',this.cDrag).index(obj);
					                        var ow = $('th:visible div:eq('+n+')',this.hDiv).width();
					                        $(obj).addClass('dragging').siblings().hide();
					                        $(obj).prev().addClass('dragging').show();
					                        this.colresize = {startXe.pageXolparseInt(obj.style.left), owown
						};
					                        $('body').css('cursor','col-resize');
					                    }
				                else if (dragtype=='vresize'//table resize
				                    {
					                        var hgo false;
					                        $('body').css('cursor','row-resize');
					                        if (obj) 
					                            {
						                            hgo true;
						                            $('body').css('cursor','col-resize');
						                            }
					                        this.vresize = {hp.heightsye.pageYwp.widthsxe.pageXhgohgo};
					                    }
				                else if (dragtype=='colMove'//column header drag
				                    {
					                        $(g.nDiv).hide();
					$(g.nBtn).hide();
					                        this.hset = $(this.hDiv).offset();
					                        this.hset.right this.hset.left + $('table',this.hDiv).width();
					                        this.hset.bottom this.hset.top + $('table',this.hDiv).height();
					                        this.dcol obj;
					                        this.dcoln = $('th',this.hDiv).index(obj);
					                        this.colCopy document.createElement("div");
					                        this.colCopy.className "colCopy";
					                        this.colCopy.innerHTML obj.innerHTML;
					                        if ($.browser.msie)
					                        {
						                        this.colCopy.className "colCopy ie";
						                        }
					                        $(this.colCopy).css({position:'absolute',float:'left',display:'none'textAlignobj.align});
					                        $('body').append(this.colCopy);
					                        $(this.cDrag).hide();
					                    }
				                $('body').noSelect();
				            },
			            dragMove: function (e) {
				                if (this.colresize//column resize
				                    {
					                        var this.colresize.n;
					                        var diff e.pageX-this.colresize.startX;
					                        var nleft this.colresize.ol diff;
					                        var nw this.colresize.ow diff;
					                        if (nw p.minwidth)
					                            {
						                                $('div:eq('+n+')',this.cDrag).css('left',nleft);
						                                this.colresize.nw nw;
						                            }
					                    }
				                else if (this.vresize//table resize
				                    {
					                        var this.vresize;
					                        var e.pageY;
					                        var diff y-v.sy;
					                        if (!p.defwidthp.defwidth p.width;
					                        if (p.width != 'auto' && !p.nohresize && v.hgo)
					                        {
						                            var e.pageX;
						                            var xdiff v.sx;
						                            var newW v.xdiff;
						                            if (newW p.defwidth)
						                                {
							                                    this.gDiv.style.width newW 'px';
							                                    p.width newW;
							                                }
						                        }
					                        var newH v.diff;
					                        if ((newH p.minheight || p.height p.minheight) && !v.hgo)
					                            {
						                                this.bDiv.style.height newH 'px';
						                                p.height newH;
						                                this.fixHeight(newH);
						                            }
					                        null;
					                    }
				                else if (this.colCopy) {
					                    $(this.dcol).addClass('thMove').removeClass('thOver');
					                    if (e.pageX this.hset.right || e.pageX this.hset.left || e.pageY this.hset.bottom || e.pageY this.hset.top)
					                    {
						                        //this.dragEnd();
						                        $('body').css('cursor','move');
						                    }
					                    else 
					                    $('body').css('cursor','pointer');
					                    $(this.colCopy).css({top:e.pageY 10,left:e.pageX 20display'block'});
					                }                                                    
				            },
			            dragEnd: function () {
				                if (this.colresize)
				                    {
					                        var this.colresize.n;
					                        var nw this.colresize.nw;
					                                $('th:visible div:eq('+n+')',this.hDiv).css('width',nw);
					                                $('tr',this.bDiv).each (
					                                    function ()
					                                        {
						                                        $('td:visible div:eq('+n+')',this).css('width',nw);
						                                        }
					                                );
					                                this.hDiv.scrollLeft this.bDiv.scrollLeft;
					                        $('div:eq('+n+')',this.cDrag).siblings().show();
					                        $('.dragging',this.cDrag).removeClass('dragging');
					                        this.rePosDrag();
					                        this.fixHeight();
					                        this.colresize false;
					                    }
				                else if (this.vresize)
				                    {
					                        this.vresize false;
					                    }
				                else if (this.colCopy)
				                    {
					                        $(this.colCopy).remove();
					                        if (this.dcolt != null)
					                            {
						                            if (this.dcoln>this.dcolt)
						                                $('th:eq('+this.dcolt+')',this.hDiv).before(this.dcol);
						                            else
						                                $('th:eq('+this.dcolt+')',this.hDiv).after(this.dcol);
						                            this.switchCol(this.dcoln,this.dcolt);
						                            $(this.cdropleft).remove();
						                            $(this.cdropright).remove();
						                            this.rePosDrag();
						                            if (p.onDragColp.onDragCol(this.dcolnthis.dcolt);
						                            }
					                        this.dcol null;
					                        this.hset null;
					                        this.dcoln null;
					                        this.dcolt null;
					                        this.colCopy null;
					                        $('.thMove',this.hDiv).removeClass('thMove');
					                        $(this.cDrag).show();
					                    }                                        
				                $('body').css('cursor','default');
				                $('body').noSelect(false);
				            },
			            toggleCol: function(cid,visible) {
				                var ncol = $("th[axis='col"+cid+"']",this.hDiv)[0];
				                var = $('thead th',g.hDiv).index(ncol);
				                var cb = $('input[value='+cid+']',g.nDiv)[0];
				                if (visible==null)
				                    {
					                        visible ncol.hide;
					                    }
				                if ($('input:checked',g.nDiv).length<p.minColToggle&&!visible) return false;
				                if (visible)
				                    {
					                        ncol.hide false;
					                        $(ncol).show();
					                        cb.checked true;
					                    }
				                else
				                    {
					                        ncol.hide true;
					                        $(ncol).hide();
					                        cb.checked false;
					                    }
				                        $('tbody tr',t).each
				                            (
				                                function ()
				                                    {
					                                        if (visible)
					                                            $('td:eq('+n+')',this).show();
					                                        else
					                                            $('td:eq('+n+')',this).hide();
					                                    }
				                            );
				                this.rePosDrag();
				                if (p.onToggleColp.onToggleCol(cid,visible);
				                return visible;
				            },
			            switchCol: function(cdrag,cdrop) {
				//switch columns
				                $('tbody tr',t).each
				                    (
				                        function ()
				                            {
					                                if (cdrag>cdrop)
					                                    $('td:eq('+cdrop+')',this).before($('td:eq('+cdrag+')',this));
					                                else
					                                    $('td:eq('+cdrop+')',this).after($('td:eq('+cdrag+')',this));
					                            }
				                    );
				                    //switch order in nDiv
				                    if (cdrag>cdrop)
				                        $('tr:eq('+cdrop+')',this.nDiv).before($('tr:eq('+cdrag+')',this.nDiv));
				                    else
				                        $('tr:eq('+cdrop+')',this.nDiv).after($('tr:eq('+cdrag+')',this.nDiv));
				                    if ($.browser.msie&&$.browser.version<7.0) $('tr:eq('+cdrop+') input',this.nDiv)[0].checked true;
				                    this.hDiv.scrollLeft this.bDiv.scrollLeft;
				            },            
			            scroll: function() {
				                    this.hDiv.scrollLeft this.bDiv.scrollLeft;
				                    this.rePosDrag();
				            },
			            addData: function (data) {
				//parse data
				                if (p.preProcess)
				                    data p.preProcess(data);
				                $('.pReload',this.pDiv).removeClass('loading');
				                this.loading false;
				                if (!data) 
				                    {
					                    $('.pPageStat',this.pDiv).html(p.errormsg);
					                    return false;
					                    }
				                if (p.dataType=='xml')
				                    p.total = +$('rows total',data).text();
				                else
				                    p.total data.total;
				                if (p.total==0)
				                    {
					                    $('tr, a, td, div',t).unbind();
					                    $(t).empty();
					                    p.pages 1;
					                    p.page 1;
					                    this.buildpager();
					                    $('.pPageStat',this.pDiv).html(p.nomsg);
					                    return false;
					                    }
				                p.pages Math.ceil(p.total/p.rp);
				                if (p.dataType=='xml')
				                    p.page = +$('rows page',data).text();
				                else
				                    p.page data.page;
				                this.buildpager();
				                //build new body
				                var tbody document.createElement('tbody');
				                if (p.dataType=='json')
				                {                    
					                    // Remove any existing hidden fields to store row ID values
					                    $('#fg_rowid_values_' p.uniqueIndex).empty('input:text');
					                    $.each
					                    (
					                     data.rows,
					                     function(i,row) 
					                         {                            
						                            var tr document.createElement('tr');
						                            if (&& p.stripedtr.className 'erow';
						                            if (row.idtr.id 'row_' p.uniqueIndex '_' i;
						                            //add cell
						                            $('thead tr:first th',g.hDiv).each
						                            (
						                                 function ()
						                                    {
							                                        var idx = $(this).attr('axis').substr(3);
							                                        if (idx == 0) {
								                                            // Add hidden fields to store row ID values
								                                            var rowId = $('<input type="text" id="fg_row_id_' p.uniqueIndex '_' '" value="' row.id '" />');
								                                            $('#fg_rowid_values_' p.uniqueIndex).append(rowId);
								}
							                                        var td document.createElement('td');
							                                        if (idx == p.displayColumn) {
								                                            td.id='fg_row_display_' p.uniqueIndex '_' i;
								}
							                                        td.align this.align;
							                                        // Write Cell Here
							                                        if (p.colModel[idx]['type'] == 'image') {
								                                            if (row.cell[idx] != '-') {
									                                                var url p.baseUrl p.imageViewer '?file=' row.cell[idx] + '&no_file=' p.defaultImage '&mode=3' '&width=' p.colModel[idx]['image_width'] + '&height=' p.colModel[idx]['image_height'];
									                                                var data '<img src="' url '" border="0" />';
									} else {
									                                                var data '&nbsp;
									';
									}
								} else if (p.colModel[idx]['type'] == 'file') {
								                                            if ((row.cell[idx] != '-')) {
									                                                var file_url p.baseUrl p.fileRequest '?file=' row.cell[idx];
									                                                var icon_url p.baseUrl p.iconRequest '?file=' row.cell[idx];
									                                                var data '<a href="' file_url '"><img src="' icon_url '" border="0" /><br />' row.cell[idx] + '</a>';
									} else {
									                                                var data '&nbsp;
									';
									}
								} else if (p.colModel[idx]['type'] == 'binary_image') {
								                                            var data '&nbsp;
								';
								                                            var info row.cell[idx].split('*');
								                                            if (info.length>=2) {
									                                                var dataLength info[0];
									                                                if (dataLength 0) {
										                                                    var fileName info[1];
										                                                    var url p.baseUrl p.imageViewer '?file=' fileName '&data_object_hash=' p.dataObject '&field_index=' p.colModel[idx]['binary_index'] + '&primary_key=' row.id '&no_file=' p.defaultImage '&mode=3' '&width=' p.colModel[idx]['image_width'] + '&height=' p.colModel[idx]['image_height'];
										                                                    var data '<img src="' url '" border="0" />';
										}
									}
								} else if (p.colModel[idx]['type'] == 'binary_file') {
								                                            var data '&nbsp;
								';
								                                            var info row.cell[idx].split('*');
								                                            if (info.length>=2) {
									                                                var dataLength info[0];
									                                                if (dataLength 0) {
										                                                    var fileName info[1];
										                                                    if (fileName != '') {
											                                                        var file_url p.baseUrl p.fileRequest '?file=' fileName '&data_object_hash=' p.dataObject '&field_index=' p.colModel[idx]['binary_index'] + '&primary_key=' row.id;
											                                                        var icon_url p.baseUrl p.iconRequest '?file=' fileName;
											                                                        var data '<a href="' file_url '"><img src="' icon_url '" border="0" /><br />' fileName '</a>';
											}
										}
									}                                        
								} else if (p.colModel[idx]['type'] == 'link_status') {
								                                            var data row.cell[idx] + '<input type="hidden" id="fg_row_' p.uniqueIndex '_' '_link_status" value="' row.cell[idx] + '" />';
								} else {
								                                            var data row.cell[idx];
								}
							                                        td.innerHTML data;
							                                        $(tr).append(td);
							                                        td null;
							                                    }
						                            );
						                            if ($('thead',this.gDiv).length<1//handle if grid has no headers
						                            {
							                                    for (idx=0;
							idx<cell.length;
							idx++)
							                                        {                                            
								                                        var td document.createElement('td');
								                                        td.innerHTML extra row.cell[idx];
								                                        $(tr).append(td);
								                                        td null;
								                                        }
							                            }                            
						                            $(tbody).append(tr);
						                            tr null;
						                        }
					                    );
					                } else if (p.dataType=='xml') {
					                1;
					                $("rows row",data).each
					                (
					                     function ()
					                        {
						                            i++;
						                            var tr document.createElement('tr');
						                            if (&& p.stripedtr.className 'erow';
						                            var nid =$(this).attr('id');
						                            if (nidtr.id 'row' nid;
						                            nid null;
						                            var robj this;
						                            $('thead tr:first th',g.hDiv).each
						                            (
						                                 function ()
						                                    {
							                                        var td document.createElement('td');
							                                        var idx = $(this).attr('axis').substr(3);
							                                        td.align this.align;
							                                        td.innerHTML = $("cell:eq("idx +")",robj).text();
							                                        $(tr).append(td);
							                                        td null;
							                                    }
						                            );
						                            if ($('thead',this.gDiv).length<1//handle if grid has no headers
						                            {
							                                $('cell',this).each
							                                (
							                                     function ()
							                                        {
								                                        var td document.createElement('td');
								                                        td.innerHTML = $(this).text();
								                                        $(tr).append(td);
								                                        td null;
								                                        }
							                                );
							                            }
						                            $(tbody).append(tr);
						                            tr null;
						                            robj null;
						                        }
					                );
					                }
				                $('tr',t).unbind();
				                $(t).empty();
				                $(t).append(tbody);
				                this.addCellProp();
				                this.addRowProp();
				                //this.fixHeight($(this.bDiv).height());
				                this.rePosDrag();
				                tbody null;
				 data null;
				 null;
				                if (p.onSuccessp.onSuccess();
				                if (p.hideOnSubmit) $(g.block).remove();
				//$(t).show();
				                this.hDiv.scrollLeft this.bDiv.scrollLeft;
				                if ($.browser.opera) $(t).css('visibility','visible');
				            },
			            changeSort: function(th) {
				//change sortorder
				                if (this.loading) return true;
				                $(g.nDiv).hide();
				$(g.nBtn).hide();
				                p.sort addSortColumn(thp.sort);
				                this.populate();
				            },
			            buildpager: function(){ //rebuild pager based on new properties
				            $('.pcontrol input',this.pDiv).val(p.page);
				            $('.pcontrol span',this.pDiv).html(p.pages);
				            var r1 = (p.page-1) * p.rp 1;
				            var r2 r1 p.rp 1;
				            if (p.total<r2r2 p.total;
				            var stat p.pagestat;
				            stat stat.replace(/{from}/,r1);
				            stat stat.replace(/{to}/,r2);
				            stat stat.replace(/{total}/,p.total);
				            $('.pPageStat',this.pDiv).html(stat);
				            },
			            populate: function () {
				//get latest data
				                $.scrollTo(00);
				                if (this.loading) return true;
				                $('#fg_view_' p.uniqueIndex).attr('className''viewRecordsButton');
				                if (p.onSubmit)
				                    {
					                        var gh p.onSubmit();
					                        if (!gh) return false;
					                    }
				                this.loading true;
				                if (!p.url) return false;
				                $('.pPageStat',this.pDiv).html(p.procmsg);
				                $('.pReload',this.pDiv).addClass('loading');
				                $(g.block).css({top:g.bDiv.offsetTop});
				                if (p.hideOnSubmit) $(this.gDiv).prepend(g.block);
				 //$(t).hide();
				                if ($.browser.opera) $(t).css('visibility','hidden');
				                if (!p.newpp.newp 1;
				                if (p.page>p.pagesp.page p.pages;
				                //var param = {page:p.newp, rp: p.rp, sort: p.sort, query: p.query, qtype: p.qtype};
				                var param = [
				                     { name 'page'value p.newp
					}
				                    ,{ name 'rp'value p.rp
					}
				                    ,{ name 'sort'value implode(p)}
				                    ,{ name 'query'value p.query}
				                    ,{ name 'qtype'value p.qtype}
				                    ,{ name 'dataObject'value p.dataObject}
				                ];
				                $('#fg_tableFilters_' p.uniqueIndex).find('*[id^=fg_R_' p.uniqueIndex ']').each( function() {
					param.push({ name this.idvalue this.value});
					});
				                 if (p.params)
				                    {
					                        for (var pi 0;
					 pi p.params.length;
					 pi++) param[param.length] = p.params[pi];
					                    }
				                    $.ajax({
					                       typep.method,
					                       urlp.baseUrl p.url,
					                       dataparam,
					                       dataTypep.dataType,
					                       success: function(data){g.addData(data);
						},
					                       error: function(XMLHttpRequesttextStatuserrorThrown) {
						try { if (p.onErrorp.onError(XMLHttpRequesttextStatuserrorThrown);
							} catch (e{}
						}
					});
				                $('#fg_active_toolbar_' p.uniqueIndex).removeClass().addClass('pDiv');
				                $('#fg_inactive_toolbar_' p.uniqueIndex).removeClass().addClass('pDivInactive');
				            },
			            doSearch: function () {
				                p.query = $('input[name=q]',g.sDiv).val();
				                p.qtype = $('select[name=qtype]',g.sDiv).val();
				                p.newp 1;
				                this.populate();
				            },
			            changePage: function (ctype){ //change page
				                if (this.loading) return true;
				                switch(ctype)
				                {
					                    case 'first'p.newp 1;
					 break;
					                    case 'prev': if (p.page>1p.newp parseInt(p.page) - 1;
					 break;
					                    case 'next': if (p.page<p.pagesp.newp parseInt(p.page) + 1;
					 break;
					                    case 'last'p.newp p.pages;
					 break;
					                    case 'input': 
					                            var nv parseInt($('.pcontrol input',this.pDiv).val());
					                            if (isNaN(nv)) nv 1;
					                            if (nv<1nv 1;
					                            else if (nv p.pagesnv p.pages;
					                            $('.pcontrol input',this.pDiv).val(nv);
					                            p.newp =nv;
					                            break;
					                }
				                if (p.newp==p.page) return false;
				                if (p.onChangePage) 
				                    p.onChangePage(p.newp);
				                else                
				                    this.populate();
				            },
			            exportData: function(format) {
				                var param = [
				                     { name 'sort'value implode(p)}
				                    ,{ name 'query'value p.query}
				                    ,{ name 'qtype'value p.qtype}
				                    ,{ name 'dataObject'value p.dataObject}
				                    ,{ name 'title'value p.title}
				                ];
				                $('#fg_tableFilters_' p.uniqueIndex).find('*[id^=fg_R_' p.uniqueIndex ']').each( function() {
					param.push({ name this.idvalue this.value});
					});
				                var url '';
				                for (var object in param) {
					                    var parameter param[object]
					                    var id parameter['name'];
					                    var value parameter['value'];
					                    url += '&' id '=' value;
					}
				                $('#hidFrame_' p.uniqueIndex).attr('src'p.baseUrl p.exportRequest '?format=' format url);
				},
			            addCellProp: function ()
			            {
				                    $('tbody tr td',g.bDiv).each
				                    (
				                        function ()
				                            {
					                                    var tdDiv document.createElement('div');
					                                    var = $('td',$(this).parent()).index(this);
					                                    var pth = $('th:eq('+n+')',g.hDiv).get(0);
					                                    if (pth!=null)
					                                    {
						                                    var val = $(pth).attr('abbr')
						                                    if (isSortColumnAdded(valp.sort) && val)
						                                        {
							                                        this.className 'sorted';
							                                        }
						                                     $(tdDiv).css({textAlign:pth.rowAlign,width: $('div:first',pth)[0].style.width});
						                                     if (pth.hide) $(this).css('display','none');
						}
					                                     if (p.nowrap==false) $(tdDiv).css('white-space','normal');
					                                     if (this.innerHTML==''this.innerHTML '&nbsp;
					';
					                                     //tdDiv.value = this.innerHTML;
					 //store preprocess value
					                                     tdDiv.innerHTML this.innerHTML;
					                                     var prnt = $(this).parent()[0];
					                                     var pid false;
					                                     if (prnt.idpid prnt.id.substr(3);
					                                     if (pth!=null)
					                                     {
						                                     if (pth.processpth.process(tdDiv,pid);
						}
					                                    $(this).empty().append(tdDiv).removeAttr('width');
					 //wrap content
					                                    //add editable event here 'dblclick'
					                            }
				                    );
				            },
			            getCellDim: function (obj// get cell prop for editable event
			            {
				                var ht parseInt($(obj).height());
				                var pht parseInt($(obj).parent().height());
				                var wt parseInt(obj.style.width);
				                var pwt parseInt($(obj).parent().width());
				                var top obj.offsetParent.offsetTop;
				                var left obj.offsetParent.offsetLeft;
				                var pdl parseInt($(obj).css('paddingLeft'));
				                var pdt parseInt($(obj).css('paddingTop'));
				                return {ht:ht,wt:wt,top:top,left:left,pdl:pdlpdt:pdtpht:phtpwtpwt};
				            },
			            addRowProp: function()
			            {
				                    $('tbody tr',g.bDiv).each
				                    (
				                        function ()
				                            {
					                            $(this)
					                            .dblclick(
					                                function (e)
					                                    {
						                                        var obj = (e.target || e.srcElement);
						 if (obj.href || obj.type) return true;
						                                        $(this).removeClass('trSelected').addClass('trSelected');
						                                        $(this).siblings().removeClass('trSelected');
						                                        if (p.onDblClick) {
							                                            p.onDblClick(pg.gDiv);
							}
						}
					                            )
					                            .click(
					                                function (e) 
					                                    { 
						                                        var obj = (e.target || e.srcElement);
						 if (obj.href || obj.type) return true;
						                                        $(this).toggleClass('trSelected');
						                                        if ((p.singleSelect) || p.type == 2) $(this).siblings().removeClass('trSelected');
						                                        if (p.onClick) {
							                                            p.onClick(pg.gDiv);
							}                                                                            
						                                    }
					                            )
					                            .mousedown(
					                                function (e)
					                                    {
						                                        if (e.shiftKey)
						                                        {
							                                        $(this).toggleClass('trSelected');
							                                        g.multisel true;
							                                        this.focus();
							                                        $(g.gDiv).noSelect();
							                                        }
						                                    }
					                            )
					                            .mouseup(
					                                function ()
					                                    {
						                                        if (g.multisel)
						                                        {
							                                        g.multisel false;
							                                        $(g.gDiv).noSelect(false);
							                                        }
						                                    }
					                            )
					                            .hover(
					                                function (e) 
					                                    { 
						                                    if (g.multisel) 
						                                        {
							                                        $(this).toggleClass('trSelected');
							                                        }
						                                    },
					                                function () {}                        
					                            )
					                            ;
					                            if ($.browser.msie&&$.browser.version<7.0)
					                                {
						                                    $(this)
						                                    .hover(
						                                        function () {
							$(this).addClass('trOver');
							},
						                                        function () {
							$(this).removeClass('trOver');
							}
						                                    )
						                                    ;
						                                }
					                            }
				                    );
				            },
			            pager0
			            };
		        //create model if any
		        if (p.colModel)
		        {
			            thead document.createElement('thead');
			            tr document.createElement('tr');
			            for (i=0;
			i<p.colModel.length;
			i++)
			                {
				                    var cm p.colModel[i];
				                    var th document.createElement('th');
				                    th.innerHTML cm.display;
				                    if (cm.name&&cm.sortable)
				                        $(th).attr('abbr',cm.name);
				                    //th.idx = i;
				                    $(th).attr('axis','col'+i);
				                    if (cm.align)
				                        th.rowAlign cm.align
				                    else
				                        th.rowAlign '';
				                    // Heading Alignment
				                    th.align 'center';
				                    if (cm.width) 
				                        $(th).attr('width',cm.width);
				                    if (cm.hide)
				                        {
					                        th.hide true;
					                        }
				                    if (cm.process)
				                        {
					                            th.process cm.process;
					                        }
				                    $(tr).append(th);
				                }
			            $(thead).append(tr);
			            $(t).prepend(thead);
			        } // end if p.colmodel    
		        //init divs
		        g.gDiv document.createElement('div');
		 //create global container
		        g.gDiv.id 'fg_grid_' p.uniqueIndex;
		        g.mDiv document.createElement('div');
		 //create title container
		        g.fDiv document.createElement('div');
		 //create filter container
		        g.hDiv document.createElement('div');
		 //create header container
		        g.hDiv.id 'fg_header_';
		        g.bDiv document.createElement('div');
		 //create body container
		        g.vDiv document.createElement('div');
		 //create grip
		        g.rDiv document.createElement('div');
		 //create horizontal resizer
		        g.cDrag document.createElement('div');
		 //create column drag
		        g.block document.createElement('div');
		 //create blocker
		        g.nDiv document.createElement('div');
		 //create column show/hide popup
		        g.nBtn document.createElement('div');
		 //create column show/hide button        
		        g.iDiv document.createElement('div');
		 //create editable layer
		        g.tDiv document.createElement('div');
		 //create toolbar
		        g.tDiv.id 'fg_toolbar_' p.uniqueIndex;
		        g.sDiv document.createElement('div');
		        if (p.usepager) {
			            g.pDiv document.createElement('div');
			 //create pager container            
			            g.pDiv.id 'fg_active_toolbar_' p.uniqueIndex;
			            g.phDiv document.createElement('div');
			 //create hidden pager replacement
			            g.phDiv.id 'fg_inactive_toolbar_' p.uniqueIndex;
			            g.phDiv.className 'pDivInactive';
			            $(g.phDiv).css('height''28px');
			}
		        g.hTable document.createElement('table');
		        //set gDiv
		        g.gDiv.className 'flexigrid';
		        //g.gDiv.id = 'fg_grid_' + uniqueIndex;
		        if ((p.width!='auto') && (p.width!='90%')) g.gDiv.style.width p.width 'px';
		        //add conditional classes
		        if ($.browser.msie)
		            $(g.gDiv).addClass('ie');
		        if (p.novstripe)
		            $(g.gDiv).addClass('novstripe');
		        $(t).before(g.gDiv);
		        $(g.gDiv)
		        .append(t)
		        ;
		        //set toolbar
		        if (p.buttons) 
		        {
			            g.tDiv.className 'tDiv';
			            var tDiv2 document.createElement('div');
			            tDiv2.className 'tDiv2';
			            for (i=0;
			i<p.buttons.length;
			i++)
			                {
				                    var btn p.buttons[i];
				                    if (!btn.separator)
				                    {
					                        var btnDiv document.createElement('div');
					                        btnDiv.className 'fbutton';
					                        btnDiv.innerHTML "<div id='" btn.id "'><span>"+btn.name+"</span></div>";
					                        if (btn.bclass) 
					                            $('span',btnDiv)
					                            .addClass(btn.bclass)
					                            .css({paddingLeft:20})
					                            ;
					                        if (!btn.visible) {
						                            $('div',btnDiv).css('display''none');
						}
					                        btnDiv.onpress btn.onpress;
					                        btnDiv.name btn.name;
					                        btnDiv.id btn.name;
					                        if (btn.onpress)
					                        {
						                            $(btnDiv).click
						                            (    
						                                function () 
						                                {
							                                this.onpress(pthis.name,g.gDiv);
							                                }
						                            );
						                        }
					                        $(tDiv2).append(btnDiv);
					                        if ($.browser.msie&&$.browser.version<7.0)
					                        {
						                            $(btnDiv).hover(function(){$(this).addClass('fbOver');
							},function(){$(this).removeClass('fbOver');
							});
						                        }
					                    } else {
					                        $(tDiv2).append("<div class='btnseparator'></div>");
					                    }
				                }
			                if (p.colModel[0]['type'] == 'link_status') {
				                    $(tDiv2).append("<div class='btnseparator'></div><div style='float: right;
				margin-top:5px;
				margin-left:100px;
				'>" language.GRID_RECORDS_MARKED "</div>");
				}
			                $(g.tDiv).append(tDiv2);
			                $(g.tDiv).append("<div style='clear:both'></div>");
			                $(g.gDiv).prepend(g.tDiv);
			        }
		        //set hDiv
		        g.hDiv.className 'hDiv';
		        $(t).before(g.hDiv);
		        //set hTable
		            g.hTable.cellPadding 0;
		            g.hTable.cellSpacing 0;
		            $(g.hDiv).append('<div class="hDivBox"></div>');
		            $('div',g.hDiv).append(g.hTable);
		            var thead = $("thead:first",t).get(0);
		            if (thead) $(g.hTable).append(thead);
		            thead null;
		        if (!p.colmodel) var ci 0;
		        //$(g.gDiv).prepend(g.fDiv);
		 // Add Filter Bar
		        $(g.gDiv).prepend($("#fg_filter_block_" p.uniqueIndex));
		        //setup thead            
		            $('thead tr:first th',g.hDiv).each
		            (
		                 function ()
		                    {
			                        var thdiv document.createElement('div');
			                        if ($(this).attr('abbr'))
			                            {
				                            $(this).click(
				                                function (e) 
				                                    {
					                                        if (!$(this).hasClass('thOver')) return false;
					                                        var obj = (e.target || e.srcElement);
					                                        if (obj.href || obj.type) return true;
					                                        g.changeSort(this);
					                                    }
				                            )
				                            ;
				                            var direction getSortDirection($(this).attr('abbr'), p.sort);
				                            if (direction) {
					                                this.className 'sorted';
					                                thdiv.className 's'+direction;
					}
				                            }
			                            if (this.hide) $(this).hide();
			                            if (!p.colmodel)
			                            {
				                                $(this).attr('axis','col' ci++);
				                            }
			                         $(thdiv).css({textAlign:this.alignwidththis.width 'px'});
			                         thdiv.innerHTML this.innerHTML;
			                        $(this).empty().append(thdiv).removeAttr('width')
			                        .mousedown(function (e) 
			                            {
				                                g.dragStart('colMove',e,this);
				                            })
			                        .hover(
			                            function(){
				                                if (!g.colresize&&!$(this).hasClass('thMove')&&!g.colCopy) $(this).addClass('thOver');
				                                var direction getSortDirection($(this).attr('abbr'), p.sort);
				                                if ((!direction)&&!g.colCopy&&!g.colresize&&$(this).attr('abbr')) $('div',this).addClass('s'+p.direction);
				                                else if (direction&&!g.colCopy&&!g.colresize&&$(this).attr('abbr'))
				                                    {
					                                        var no '';
					                                        if (direction=='asc'no 'desc';
					                                        else no 'asc';
					                                        $('div',this).removeClass('s'+direction).addClass('s'+no);
					                                    }
				                                if (g.colCopy) 
				                                    {
					                                    var = $('th',g.hDiv).index(this);
					                                    if (n==g.dcoln) return false;
					                                    if (n<g.dcoln) $(this).append(g.cdropleft);
					                                    else $(this).append(g.cdropright);
					                                    g.dcolt n;
					                                    } else if (!g.colresize) {
					                                    var nv = $('th:visible',g.hDiv).index(this);
					                                    var onl parseInt($('div:eq('+nv+')',g.cDrag).css('left'));
					                                    //var nw = 0;
					 //
					                                    if (jQuery.isFunction(jQuery(g.nBtn).outerWidth)) {var nw jQuery(g.nBtn).outerWidth();
						}
					                                    nl onl nw Math.floor(p.cgwidth/2);
					                                    $(g.nDiv).hide();
					$(g.nBtn).hide();
					                                    $(g.nBtn).css({'left':nl,top:g.hDiv.offsetTop}).show();
					                                    var ndw parseInt($(g.nDiv).width());
					                                    $(g.nDiv).css({top:g.bDiv.offsetTop});
					                                    if ((nl+ndw)>$(g.gDiv).width())
					                                        $(g.nDiv).css('left',onl-ndw+1);
					                                    else
					                                        $(g.nDiv).css('left',nl);
					                                    if ($(this).hasClass('sorted')) 
					                                        $(g.nBtn).addClass('srtd');
					                                    else
					                                        $(g.nBtn).removeClass('srtd');
					                                    }
				                            },
			                            function(){
				                                $(this).removeClass('thOver');
				                                var direction getSortDirection($(this).attr('abbr'), p.sort);
				                                if (!direction) $('div',this).removeClass('sasc').removeClass('sdesc');
				                                else if (direction)
				                                    {
					                                        var no '';
					                                        if (direction=='asc'no 'desc';
					                                        else no 'asc';
					                                        $('div',this).addClass('s'+direction).removeClass('s'+no);
					                                    }
				                                if (g.colCopy) 
				                                    {                                
					                                    $(g.cdropleft).remove();
					                                    $(g.cdropright).remove();
					                                    g.dcolt null;
					                                    }
				                            })
			                        ;
			 //wrap content
			                    }
		            );
		        //set bDiv
		        g.bDiv.className 'bDiv';
		        $(t).before(g.bDiv);
		        $(g.bDiv)
		        .css({ height: (p.height=='auto') ? 'auto' p.height+"px"})
		        .scroll(function (e) {g.scroll()})
		        .append(t)
		        ;
		        if (p.height == 'auto') 
		            {
			            $('table',g.bDiv).addClass('autoht');
			            }
		        //add td properties
		        g.addCellProp();
		        //add row properties
		        g.addRowProp();
		        //set cDrag
		        var cdcol = $('thead tr:first th:first',g.hDiv).get(0);
		        if (cdcol != null)
		        {        
			        g.cDrag.className 'cDrag';
			        g.cdpad 0;
			        g.cdpad += (isNaN(parseInt($('div',cdcol).css('borderLeftWidth'))) ? parseInt($('div',cdcol).css('borderLeftWidth')));
			        g.cdpad += (isNaN(parseInt($('div',cdcol).css('borderRightWidth'))) ? parseInt($('div',cdcol).css('borderRightWidth')));
			        g.cdpad += (isNaN(parseInt($('div',cdcol).css('paddingLeft'))) ? parseInt($('div',cdcol).css('paddingLeft')));
			        g.cdpad += (isNaN(parseInt($('div',cdcol).css('paddingRight'))) ? parseInt($('div',cdcol).css('paddingRight')));
			        g.cdpad += (isNaN(parseInt($(cdcol).css('borderLeftWidth'))) ? parseInt($(cdcol).css('borderLeftWidth')));
			        g.cdpad += (isNaN(parseInt($(cdcol).css('borderRightWidth'))) ? parseInt($(cdcol).css('borderRightWidth')));
			        g.cdpad += (isNaN(parseInt($(cdcol).css('paddingLeft'))) ? parseInt($(cdcol).css('paddingLeft')));
			        g.cdpad += (isNaN(parseInt($(cdcol).css('paddingRight'))) ? parseInt($(cdcol).css('paddingRight')));
			        $(g.bDiv).before(g.cDrag);
			        var cdheight = $(g.bDiv).height();
			        var hdheight = $(g.hDiv).height();
			        $(g.cDrag).css({top: -hdheight 'px'});
			        $('thead tr:first th',g.hDiv).each
			            (
			                 function ()
			                    {
				                        var cgDiv document.createElement('div');
				                        $(g.cDrag).append(cgDiv);
				                        if (!p.cgwidthp.cgwidth = $(cgDiv).width();
				                        $(cgDiv).css({heightcdheight hdheight})
				                        .mousedown(function(e){g.dragStart('colresize',e,this);
					})
				                        ;
				                        if ($.browser.msie&&$.browser.version<7.0)
				                        {
					                            g.fixHeight($(g.gDiv).height());
					                            $(cgDiv).hover(
					                                function () 
					                                {
						                                g.fixHeight();
						                                $(this).addClass('dragging') 
						                                },
					                                function () {
						if (!g.colresize) $(this).removeClass('dragging')
						}
					                            );
					                        }
				                    }
			            );
			        //g.rePosDrag();
			        }
		        //add strip        
		        if (p.striped) 
		            $('tbody tr:odd',g.bDiv).addClass('erow');
		        if (p.resizable && p.height !='auto') 
		        {
			        g.vDiv.className 'vGrip';
			        $(g.vDiv)
			        .mousedown(function (e) {
				g.dragStart('vresize',e)})
			        .html('<span></span>');
			        $(g.bDiv).after(g.vDiv);
			        }
		        if (p.resizable && p.width !='auto' && !p.nohresize) 
		        {
			        g.rDiv.className 'hGrip';
			        $(g.rDiv)
			        .mousedown(function (e) {g.dragStart('vresize',e,true);
				})
			        .html('<span></span>')
			        .css('height',$(g.gDiv).height())
			        ;
			        if ($.browser.msie&&$.browser.version<7.0)
			        {
				            $(g.rDiv).hover(function(){$(this).addClass('hgOver');
					},function(){$(this).removeClass('hgOver');
					});
				        }
			        $(g.gDiv).append(g.rDiv);
			        }
		        // add pager
		        if (p.usepager)
		        {
			        g.pDiv.className 'pDiv';
			        g.pDiv.innerHTML '<div class="pDiv2"></div>';
			        $(g.bDiv).after(g.pDiv);
			        var html ' <div class="pGroup"> <div class="pFirst pButton"><span></span></div><div class="pPrev pButton"><span></span></div> </div> <div class="btnseparator"></div> <div class="pGroup"><span class="pcontrol">'+p.pagetext+' <input type="text" size="4" value="1" /> '+p.outof+' <span> 1 </span></span></div> <div class="btnseparator"></div> <div class="pGroup"> <div class="pNext pButton"><span></span></div><div class="pLast pButton"><span></span></div> </div> <div class="btnseparator"></div> <div class="pGroup"> <div class="pReload pButton"><span></span></div> </div> <div class="btnseparator"></div> <div class="pGroup"><span class="pPageStat"></span></div><div class="btnseparator"><div class="pGroup">';
			        if (p.exportToPDF || p.exportToWord || p.exportToExcel) {
				            html html '<div style="margin-top:4px;
				">' language.GRID_EXPORT_ALL ': </div>';
				}
			        html html '</div>';
			        if (p.exportToPDF) {
				            html html '<div class="pPDF pButton"></div>';
				}
			        if (p.exportToWord) {
				            html html '<div class="pWord pButton"></div>';
				}
			        if (p.exportToExcel) {
				            html html '<div class="pExcel pButton"></div>';
				}
			        html html '<iframe id="hidFrame_' p.uniqueIndex '" style="display:none;
			"></iframe>';
			        $('div',g.pDiv).html(html);
			        $('.pReload',g.pDiv).click(function(){g.populate()});
			        $('#fg_view_' p.uniqueIndex).click(function(){g.populate()});
			        $('.pFirst',g.pDiv).click(function(){g.changePage('first')});
			        $('.pPrev',g.pDiv).click(function(){g.changePage('prev')});
			        $('.pNext',g.pDiv).click(function(){g.changePage('next')});
			        $('.pLast',g.pDiv).click(function(){g.changePage('last')});
			        $('.pPDF',g.pDiv).click(function(){g.exportData('pdf');
				});
			        $('.pExcel',g.pDiv).click(function(){g.exportData('excel')});
			        $('.pWord',g.pDiv).click(function(){g.exportData('word')});
			        $('.pcontrol input',g.pDiv).keydown(function(e){if(e.keyCode==13g.changePage('input')});
			        if ($.browser.msie&&$.browser.version<7) $('.pButton',g.pDiv).hover(function(){$(this).addClass('pBtnOver');
				},function(){$(this).removeClass('pBtnOver');
				});
			            if (p.useRp)
			            {
				            var opt "";
				            for (var nx=0;
				nx<p.rpOptions.length;
				nx++)
				            {
					                if (p.rp == p.rpOptions[nx]) sel 'selected="selected"';
					 else sel '';
					                 opt += "<option value='" p.rpOptions[nx] + "' " sel " >" p.rpOptions[nx] + "&nbsp;
					&nbsp;
					</option>";
					            };
				            $('.pDiv2',g.pDiv).prepend("<div class='pGroup'><select name='rp'>"+opt+"</select></div> <div class='btnseparator'></div>");
				            $('select',g.pDiv).change(
				                    function ()
				                    {
					                        if (p.onRpChange) 
					                            p.onRpChange(+this.value);
					                        else
					                            {
						                            p.newp 1;
						                            p.rp = +this.value;
						                            g.populate();
						                            }
					                    }
				                );
				            }
			        //add search button
			        if (p.searchitems)
			            {
				                $('.pDiv2',g.pDiv).prepend("<div class='pGroup'> <div class='pSearch pButton'><span></span></div> </div>  <div class='btnseparator'></div>");
				                $('.pSearch',g.pDiv).click(function(){$(g.sDiv).slideToggle('fast',function(){$('.sDiv:visible input:first',g.gDiv).trigger('focus');
						});
					});
				                //add search box
				                g.sDiv.className 'sDiv';
				                sitems p.searchitems;
				                var sopt "";
				                for (var 0;
				 sitems.length;
				 s++)
				                {
					                    if (p.qtype=='' && sitems[s].isdefault==true)
					                    {
						                    p.qtype sitems[s].name;
						                    sel 'selected="selected"';
						                    } else sel '';
					                    sopt += "<option value='" sitems[s].name "' " sel " >" sitems[s].display "&nbsp;
					&nbsp;
					</option>";
					                }
				                if (p.qtype==''p.qtype sitems[0].name;
				                $(g.sDiv).append("<div class='sDiv2'>"+p.findtext+" <input type='text' size='30' name='q' class='qsbox' /> <select name='qtype'>"+sopt+"</select> <!--input type='button' value='Clear' /--></div>");
				                $('input[name=q],select[name=qtype]',g.sDiv).keydown(function(e){if(e.keyCode==13g.doSearch()});
				                $('input[value=Clear]',g.sDiv).click(function(){$('input[name=q]',g.sDiv).val('');
					 p.query '';
					 g.doSearch();
					});
				                $(g.bDiv).after(g.sDiv);
				            }
			        }
		        $(g.bDiv).after(g.phDiv);
		        $(g.pDiv,g.sDiv).append("<div style='clear:both'></div>");
		        // add filter
		        g.fDiv.className 'mDiv';
		        g.fDiv.innerHTML '<div class="filterHeading"></div>';
		        // add title
		        if (p.title)
		        {
			            g.mDiv.className 'mDiv';
			            g.mDiv.innerHTML '<div class="ftitle">'+p.title+'</div>';
			            $(g.gDiv).prepend(g.mDiv);
			            if (p.showTableToggleBtn)
			                {
				                    $(g.mDiv).append('<div class="ptogtitle" title="Minimize/Maximize Table"><span></span></div>');
				                    $('div.ptogtitle',g.mDiv).click
				                    (
				                         function ()
				                            {
					                                $(g.gDiv).toggleClass('hideBody');
					                                $(this).toggleClass('vsble');
					                            }
				                    );
				                }
			            //g.rePosDrag();
			        }
		        //setup cdrops
		        g.cdropleft document.createElement('span');
		        g.cdropleft.className 'cdropleft';
		        g.cdropright document.createElement('span');
		        g.cdropright.className 'cdropright';
		        //add block
		        g.block.className 'gBlock';
		        var gh = $(g.bDiv).height();
		        var gtop g.bDiv.offsetTop;
		        $(g.block).css(
		        {
			            widthg.bDiv.style.width,
			            heightgh,
			            background'white',
			            position'relative',
			            marginBottom: (gh * -1),
			            zIndex1,
			            topgtop,
			            left'0px'
			        }
		        );
		        $(g.block).fadeTo(0,p.blockOpacity);
		        // add column control
		        if ($('th',g.hDiv).length)
		        {
			            g.nDiv.className 'nDiv';
			            g.nDiv.innerHTML "<table cellpadding='0' cellspacing='0'><tbody></tbody></table>";
			            $(g.nDiv).css(
			            {
				                marginBottom: (gh * -1),
				                display'none',
				                topgtop
				            }
			            ).noSelect()
			            ;
			            var cn 0;
			            $('th div',g.hDiv).each
			            (
			                 function ()
			                    {
				                        var kcol = $("th[axis='col" cn "']",g.hDiv)[0];
				                        var chk 'checked="checked"';
				                        if (kcol.style.display=='none'chk '';
				                        $('tbody',g.nDiv).append('<tr><td class="ndcol1"><input type="checkbox" 'chk +' class="togCol" value="'cn +'" /></td><td class="ndcol2">'+this.innerHTML+'</td></tr>');
				                        cn++;
				                    }
			            );
			            if ($.browser.msie&&$.browser.version<7.0)
			                $('tr',g.nDiv).hover
			                (
			                     function () {$(this).addClass('ndcolover');
				},
			                    function () {$(this).removeClass('ndcolover');
				}
			                );
			            $('td.ndcol2',g.nDiv).click
			            (
			                 function ()
			                    {
				                        if ($('input:checked',g.nDiv).length<=p.minColToggle&&$(this).prev().find('input')[0].checked) return false;
				                        return g.toggleCol($(this).prev().find('input').val());
				                    }
			            );
			            $('input.togCol',g.nDiv).click
			            (
			                 function ()
			                    {
				                        if ($('input:checked',g.nDiv).length<p.minColToggle&&this.checked==false) return false;
				                        $(this).parent().next().trigger('click');
				                        //return false;
				                    }
			            );
			            $(g.gDiv).prepend(g.nDiv);
			            $(g.nBtn).addClass('nBtn')
			            .html('<div></div>')
			            .attr('title','Hide/Show Columns')
			            .click
			            (
			                 function ()
			                {
				                 $(g.nDiv).toggle();
				 return true;
				                }
			            );
			            if (p.showToggleBtn) $(g.gDiv).prepend(g.nBtn);
			        }
		        // add date edit layer
		        $(g.iDiv)
		        .addClass('iDiv')
		        .css({display:'none'})
		        ;
		        $(g.bDiv).append(g.iDiv);
		        // add flexigrid events
		        $(g.bDiv)
		        .hover(function(){$(g.nDiv).hide();
			$(g.nBtn).hide();
			},function(){if (g.multiselg.multisel false;
			})
		        ;
		        $(g.gDiv)
		        .hover(function(){},function(){$(g.nDiv).hide();
			$(g.nBtn).hide();
			})
		        ;
		        //add document events
		        $(document)
		        .mousemove(function(e){g.dragMove(e)})
		        .mouseup(function(e){g.dragEnd()})
		        .hover(function(){},function (){g.dragEnd()})
		        ;
		        //browser adjustments
		        if ($.browser.msie&&$.browser.version<7.0)
		        {
			            $('.hDiv,.bDiv,.mDiv,.pDiv,.vGrip,.tDiv, .sDiv',g.gDiv)
			            .css({width'100%'});
			            $(g.gDiv).addClass('ie6');
			            if (p.width!='auto') $(g.gDiv).addClass('ie6fullwidthbug');
			        } 
		        g.rePosDrag();
		        g.fixHeight();
		        //make grid functions accessible
		        t.p;
		        t.grid g;
		        // load data
		        if (p.url&&p.autoload) 
		            {
			            g.populate();
			            }
		        return t;
		    };
	    var docloaded false;
	    $(document).ready(function () {docloaded true} );
	    $.fn.flexigrid = function(p) {
		        return this.each( function() {
			                if (!docloaded)
			                {
				                    $(this).hide();
				                    var this;
				                    $(document).ready
				                    (
				                        function ()
				                        {
					                        $.addFlex(t,p);
					                        }
				                    );
				                } else {
				                    $.addFlex(this,p);
				                }
			            });
		    };
	 //end flexigrid
	    $.fn.flexReload = function(p) {
		// function to reload grid
		        return this.each( function() {
			                if (this.grid&&this.p.urlthis.grid.populate();
			            });
		    };
	 //end flexReload
	    $.fn.clearSortColumns = function(p) {
		        for (var column in p.sort) {
			            delete p.sort[column];
			}
		        $('div').removeClass('sasc');
		        $('div').removeClass('sdesc');
		        $('th').removeClass('sorted');
		        this.flexReload();
		}
	    $.fn.flexOptions = function(p) {
		//function to update general options
		        return this.each( function() {
			                if (this.grid) $.extend(this.p,p);
			            });
		    };
	 //end flexOptions
	    $.fn.flexToggleCol = function(cid,visible) {
		// function to reload grid
		        return this.each( function() {
			                if (this.gridthis.grid.toggleCol(cid,visible);
			            });
		    };
	 //end flexToggleCol
	    $.fn.flexAddData = function(data) {
		// function to add data to grid
		        return this.each( function() {
			                if (this.gridthis.grid.addData(data);
			            });
		    };
	    $.fn.noSelect = function(p) {
		//no select plugin by me :-)
		        if (== null) 
		            prevent true;
		        else
		            prevent p;
		        if (prevent) {
			        return this.each(function ()
			            {
				                if ($.browser.msie||$.browser.safari) $(this).bind('selectstart',function(){return false;
					});
				                else if ($.browser.mozilla) 
				                    {
					                        $(this).css('MozUserSelect','none');
					                        $('body').trigger('focus');
					                    }
				                else if ($.browser.opera) $(this).bind('mousedown',function(){return false;
					});
				                else $(this).attr('unselectable','on');
				            });
			        } else {
			        return this.each(function ()
			            {
				                if ($.browser.msie||$.browser.safari) $(this).unbind('selectstart');
				                else if ($.browser.mozilla) $(this).css('MozUserSelect','inherit');
				                else if ($.browser.opera) $(this).unbind('mousedown');
				                else $(this).removeAttr('unselectable','on');
				            });
			        }
		    };
	 //end noSelect
	})(jQuery);





PHP Demo Source Code Index