Class QDataGridLegacyBase
NOTE: Due to the use of "Eval" and HTML4 specific tags, this class is now deprecated and the name has been changed from QDataGrid to QDataGridLegacy.
DataGrid control is used to display tabular information (e.g. lists)
The control itself will display things based off of an array of objects that gets set as the "Data Source". It is particularly useful when combined with the Class::LoadArrayByXXX() functions or the Class::LoadAll() that is generated by the CodeGen framework, or when combined with custom Class ArrayLoaders that you define youself, but who's structure is based off of the CodeGen framework.
The DataGrid essentially is a
<
table>. For each item in a datasource's Array, a row (
The HTML looks for the special back-tick character "", and will do PHP Eval's on antyhing within a pair of
`.
Moreover, the special variable $_ROW can be used to access the actual contents of that particular row's data
in the main data source array.
So, for example, supposed the following: $strSimpleArray = {"Blah", "Foo", "Baz", "Fun"}; $dtgDataGrid = new DataGrid("dtgDataGrid"); $dtgDataGrid->AddColumn("Column Heading", "Contents: $_ROW
"); $dtgDataGrid->DataSource = $strSimpleArray;
This will generate a simple 4-row, 1-column table that contains the following: Column Heading -------------- Contents: Blah Contents: Foo Contents: Baz Contents: Fun
In this case, $_ROW is a string, itself, which is each item in the DataSource's array.
Utilizing the back-tick and $_ROW feature, you can do infinitely more complicatd display functionality: $dtgDataGrid = new DataGrid("dtgDataGrid"); $dtgDataGrid->AddColumn("Title", "$_ROW->Title
"); $dtgDataGrid->AddColumn("Calculated Result", "DisplayResults($_ROW->Calculate())
"); $dtgDataGrid->DataSource = Foo::LoadAll();
This could then generate a table with much more data-rich information: Title Calculated Result ----------------- -------------------- Some Title Here $28,298.24 Foo Baz Bar $18,000.00 Blah (None)
In this case, $_ROW is actually a Foo object.
IMPORTANT: Please note that while all properties can/should be set up only once within the form's !IsPostBack() clause, the DataSource MUST be set EVERY TIME. The contents of DataSource do NOT persist from postback to postback.
The appearance of the datagrid control appears to be complicated, but keep in mind that it simply utlizes the cascading nature of how browsers render tables based on styles assigned to the
<
table>,
<
table> tag. - Appearance properties defined to a specific row's DataGridRowStyle will show up as HTML attributes within that specific row's
So, attributes will only show up if it is defined at that particular level. So if you define a background color for a DataGridRowStyle for a particular row, but not for a DataGridColumn or for the DataGrid in general, that background style will only show up in that row.
And due to the cascaiding nature of how browsers render tables, any undefined appearance property will simply inherit from the parent (where a
<
table>, and any defined appearance property will simply override whatever was defined by the parent.
Sorting
Whether or not a column can be sorted depends on whether or not you define a SortByCommand (and subsequently a ReverseSortByComamnd) on the DataGridColumn itself. This SortByCommand is meant to be the SQL syntax used in an "ORDER BY" clause of a SQL query. This fits in really well with the CodeGen Framework's Class::LoadArrayByXXX() and Class::LoadAll() which takes "$strSortInfo" as an optional parameter. If a DataGrid is being sorted by a specific column, DataGrid::SortInfo will return to you the contents of DataGridColumn::SortByCommand (or ReverseSortByCommand if it's a reverse sort) for the specific column being sorted by. Therefore, you can set up your data source like: $dtgDataGrid->DataSource = Foo::LoadAll($dtgDataGrid->SortInfo);
Pagination
Pagination can be toggled on and off with the DataGrid::Paginate flag. When enabling pagination, you must specify how many items, TOTAL, are in the full list (DataGrid::TotalItemCount). The DataGrid will then automatically calculate the SQL Limit information (as used in a "LIMIT" clause of a SQL query) to be used when querying a specific subset of the total list. As with sorting, this fits really well with the CodeGen Framework's LoadArray methods which takes $strLimitInfo" as an optional parameter. Moreover, the codegen also auto-generates CountBy methods for every LoadAll/LoadArray method it generates to assist with the DataGrid::TotalItemCount property: $dtgDataGrid->TotalItemCount = Foo::CountAll(); $dtgDataGrid->DataSource = Foo::LoadAll($dtgDataGrid->SortInfo, $dtgDataGrid->LimitInfo);
Due to a bug with PHP, you cannot set a property of a property. DataGrid's AlternateRowStyle, HeaderRowStyle and RowStyle are obviously instances of DataGridRowStyle objects which have properties in and of themselves. So unfortuantely, the following code will NOT work: $dtgDataGrid->RowStyle->BackColor = "blue"; Instead, you will need to do the following: $objRowStyle = $dtgDataGrid->RowStyle; $objRowStyle->BackColor = "blue";
- QBaseClass
- QHtmlAttributeManagerBase
- QHtmlAttributeManager
- QControlBase
- QControl
- QPaginatedControl uses QDataBinder
- QDataGridLegacyBase
Direct known subclasses
QDataGridLegacy
public
|
#
AddRowAction(
Add an action on a row of this QDataGridLegacy |
public
|
#
__construct(
Constructor |
public
|
|
public
|
#
AddColumnAt( integer $intColumnIndex,
Add a column at a given index |
public
|
#
RemoveColumn( integer $intColumnIndex )
Removes a column from the datagrid given the index of the column |
public
|
#
RemoveColumnByName( string $strName )
Removes a column from the datagrid (the first column that matches) given the name of the column |
public
|
|
public
|
|
public
array|
|
|
public
|
|
public
|
|
public
|
#
GetColumnsByName( string $strName )
Returns an array of columns of same name from the QDataGridLegacy |
public
|
#
OverrideRowStyle( integer $intRowIndex,
Overrides the style of a QDataGridLegacy row given a style object |
protected
string
|
#
ParseColumnHtml(
Wrapper around static function ParseHtml of this class |
public static
string
|
#
ParseHtml( string $strHtml,
Parses the HTML written in the template and replaces the value of expressions and returns the HTML Used upon rendering to find backticks and perform PHP eval's |
public
|
#
ParsePostData( )
This method does absolutely nothing and is here because of constraints (derived from an abstract class) This is because the Table, itself, should have no actions defined on it and should not be parsing anything |
public
|
#
Sort_Click( string $strFormId, string $strControlId, string $strParameter )
Parse the _POST to see if the user is requesting a change in the sort column or page NOTE: This is an event handler (hence not all parameters of this method are used in its body) |
protected
string
|
#
GetPaginatorRowHtml(
Get the HTML for the paginator associated with this QDataGridLegacy |
protected
string
|
#
GetHeaderSortedHtml(
Returns the HTML for the row header if the result was sorted by that row |
protected
string
|
|
protected
string
|
|
protected
|
#
GetFooterRowHtml( )
Returns the footer row HTML NOTE: This function currently does nothing but is available for overriding |
protected
string
|
|
protected
|
|
protected
string
|
|
protected
string
|
#
GetColumnFilterControlId(
Returns the filter control ID for a column |
public
|
#
GetFilterControl(
Returns filter control for a given QDataGridLegacyColumn |
public
null|
|
#
GetResetButton(
Returns the reset button for the QDataGridLegacy which will be used in the filter row (filter row is the row at the top for filtering data) |
protected
|
#
CreateFilterControl( string $strControlId,
CreateControls used in the filter row and set their fiter values if available. NOTE: this function, btnReset_Click and GetControlValue are the functions to override/change if you want to add new types |
protected
|
|
protected
|
#
filterTextBox_Create( string $strControlId, string $strControlName, integer $columns, string $strValue )
This function creates a textbox suitable for the filter bar |
protected
|
#
filterListBox_Create( string $strControlId, string $strControlName, string[] $arrListValues, string $strSelectedValue )
This function creates a listbox suitable for the filter bar |
protected
|
|
protected
|
|
protected
|
#
objWaitIcon_Create( )
Creates the objWaitIcon for this datagrid, since we don't want to use the default form one |
public
|
#
btnFilter_Click( string $strFormId, string $strControlId, string $strParameter )
For each column, get its input filter value and set the columns filter with it. NOTE: this is a regular event handler method |
public
|
|
public
|
#
btnFilterReset_Click( string $strFormId, string $strControlId, string $strParameter )
Click handler for the reset button NOTE: This function, GetControlValue and CreateControl are the functions to override/change if you want to add new types |
public
|
|
public
array
|
|
public
mixed
|
|
public
|
|
public
mixed
|
|
public
mixed
|
DataBind(),
Validate()
|
OverrideAttributes(),
__call()
|
CallDataBinder(),
GetForm(),
HasDataBinder(),
SetDataBinder(),
Sleep(),
Wakeup()
|
CommentEnd,
CommentStart
|
protected
null| |
$objAlternateRowStyle
Row style for alternate rows |
#
null
|
protected
null| |
$objHeaderRowStyle
Style for the top row (not the filter row) |
#
null
|
protected
null| |
$objFilterRowStyle
Style for the filter row (not the top row) |
#
null
|
protected
null| |
$objOverrideRowStyleArray
List of styles for corresponding rows (in intRowNumber => objStyleObject style) |
#
null
|
protected
null| |
$objHeaderLinkStyle
Style object for the links header |
#
null
|
protected
null| |
$objRowStyle
Row style for rown in the datagrid |
#
null
|
protected
string| |
$objWaitIcon
Wait icon for Ajax Actions |
#
'default'
|
protected
integer
|
$intCellPadding
CellPadding. Deprecated. |
#
-1
|
protected
integer
|
$intCellSpacing
CellSpacing. Deprecated. |
#
-1
|
protected
boolean
|
$blnShowHeader
Show the header for the table? |
#
true
|
protected
boolean
|
$blnShowFilter
Determines if the filter row has to be shown or not |
#
false
|
protected
boolean
|
$blnShowFilterButton
Determines if the filter button has to be shown or not |
#
true
|
protected
boolean
|
$blnShowFilterResetButton
Determines if the reset button on the filter row has to be shown or not |
#
true
|
protected
boolean
|
$blnShowFooter
Determines of the footer has to be shown or not |
#
false
|
protected
Deprecated.
|
$strGridLines
Rules attribute of table. Not supported in HTML 5. |
|
protected
|
$objColumnArray
|
|
protected
integer
|
$intRowCount
Number of rows in the current render |
#
0
|
protected
integer
|
$intCurrentRowIndex
The index of the row being processed (This variable is used internally) |
|
protected
integer
|
$intSortColumnIndex
Column index by which we are sorting the results |
#
-1
|
protected
integer
|
$intCurrentColumnId
The index of column under consideration (This variable is used internally) |
#
1
|
protected
integer
|
$intSortDirection
Sort is ascending (0) or descending (1) |
#
0
|
protected
string
|
$strLabelForNoneFound
Format string for the label to show on the paginator when no result is found (Please see constructor for default values) |
|
protected
string
|
$strLabelForOneFound
Format string for the label to show on the paginator when one result is found (Please see constructor for default values) |
|
protected
string
|
$strLabelForMultipleFound
Format string for the label to show on the paginator when more than one entry is found (Please see constructor for default values) |
|
protected
string
|
$strLabelForPaginated
Format string for the label to show on the paginator indicating current results window This format string is responsible for telling the user about the current chunk of results that he/she is viewing. It produces strings like: - Results: Viewing Cars 11-20 of 72
|
|
protected
string
|
$strRowActionParameterHtml
String which evaluates as the ActionParameter for row of the result. This one is used for passing a string as an action parameter for the entire row and can be used inside an event handler which handles click on an entire row of the QDataGridLegacy. The event handler will recieve the value determined by the evaluation of this string. |
|
protected
|
$objRowEventArray
List of events for which actions have to be taken |
#
array()
|
protected
|
$objRowActionArray
List of actions to be taken (elements will correspond to the row event array) |
#
array()
|
protected
null
|
$objOwner
Owner table of this QDataGridLegacy (not being used right now) |
#
null
|
protected
null| |
$btnFilter
Button for filtering results (is rendered on the filter row on top) |
#
null
|
protected
array| |
$btnFilterResetArray
|
#
array()
|
protected
|
$prxDatagridSorting
Proxy used for sorting QDataGridLegacy by a particular column |
$blnIsBlockElement,
$blnUseAjax,
$objDataSource,
$objPaginator,
$objPaginatorAlternate,
$strNoun,
$strNounPlural
|
$attributes,
$styles
|
$objDataBinder
|
public
|
$AlternateRowStyle
is the DataGridRowStyle object that defines how "alternating rows" should be displayed |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public
|
$HeaderRowStyle
is the DataGridRowStyle object that defines how the "header row" should be displayed (attributes that get rendred in the header row's
public
$FilterRowStyle
|
The row style for the filter row at the top
public
$HeaderLinkStyle
|
is the DataGridRowStyle object that defines how links, specifically, in the header row should be displayed. Basically, anything defined here will show up as html attributes and css styles within the '' tag of the link, itself, in the header. Links in the header ONLY GET DISPLAYED when a column is sortable
public
$RowStyle
|
is the main or "default" DataGridRowStyle for the entire table. Any overriding row style (see "OverrideRowStyle(int, DataGridRowStyle)" below) or any appearance properties set in AlternateRowStyle or HeaderRowStyle will be applied in those specific situations. Any appearance properties NOT set in ovverrides, alternate, or header will simply default to what RowStyle has defined.
public
integer
$CellPadding
|
refers the the HTML CellPadding attribute of the < table>. Not supported in HTML 5.
public
integer
$CellSpacing
|
refers the the HTML CellSpacing attribute of the < table> Not supported in HTML 5.
public
string
$GridLines
|
refers the the HTML rules attribute of the < table>. Not supported in HTML 5.
public
boolean
$ShowHeader
|
is the flag of whether or not to show the Header row
public
boolean
$ShowFooter
|
public
boolean
$ShowFilter
|
public
boolean
$ShowFilterButton
|
Should the filter button (on filter row) be shown?
public
boolean
$ShowFilterResetButton
|
Should the reset filter button (on filter row) be shown?
public
mixed
$OrderByClause
|
public
mixed
$SortInfo
|
public
integer
$SortColumnIndex
|
is the current column that is being "sorted by" (or -1 if none)
public
integer
$SortDirection
|
specifies the direction of that sort, 0 for SortBy, and 1 for ReverseSortBy
public
string
$LabelForNoneFound
|
Format string for the label to show on the paginator when no result is found
public
string
$LabelForOneFound
|
Format string for the label to show on the paginator when one result is found
public
string
$LabelForMultipleFound
|
Format string for the label to show on the paginator when more than one result is found
public
string
$LabelForPaginated
|
Format string for the label to show on the paginator indicating current results window
public
mixed
$Owner
|
public
mixed
$FilterInfo
|
public
mixed
$Conditions
|
public read-only
integer
$CurrentRowIndex
|
is the current row index that is being rendered. Useful for render-helper functions that may get called when rendering the datagrid, itself
public read-only
$FilterButton
|
Button to filter the results (if filtering is enabled)
public read-only
$WaitIcon
|
Wait icon (e.g. a spinner) to be shown while filtering is being done on the server
public write-only
$Paginator
|
Paginator to go browse through results
public write-only
$PaginatorAlternate
|
A second paginator to go browse through results (can be used at bottom)
public write-only
boolean
$UseAjax
|
Will the paginator use AJAX or not
public write-only
string
$RowActionParameterHtml
|
String which evaluates as the ActionParameter for row of the result. |
$DataSource,
$ItemCount,
$ItemsOffset,
$ItemsPerPage,
$LimitClause,
$LimitInfo,
$Noun,
$NounPlural,
$PageCount,
$PageNumber,
$TotalItemCount
|
$AccessKey,
$AltText,
$BackColor,
$BorderCollapse,
$BorderColor,
$BorderStyle,
$BorderWidth,
$CssClass,
$Cursor,
$Data,
$Display,
$DisplayStyle,
$Enabled,
$FontBold,
$FontItalic,
$FontNames,
$FontOverline,
$FontSize,
$FontStrikeout,
$FontUnderline,
$ForeColor,
$Height,
$HorizontalAlign,
$Left,
$Margin,
$NoWrap,
$Opacity,
$OrderedListType,
$Overflow,
$Padding,
$Position,
$ReadOnly,
$TabIndex,
$ToolTip,
$Top,
$UnorderedListStyle,
$VerticalAlign,
$Width
|