browse_box
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
browse_box [2024/12/02 04:11] – added php to code tag wtkadmin | browse_box [2024/12/02 04:14] (current) – added php to code tags wtkadmin | ||
---|---|---|---|
Line 5: | Line 5: | ||
As an example of the simplest use, these few lines create a fully functioning page by calling **wtkFillBrowsePage** which is a wrapper for both **wtkBuildDataBrowse** and **wtkMergePage**. | As an example of the simplest use, these few lines create a fully functioning page by calling **wtkFillBrowsePage** which is a wrapper for both **wtkBuildDataBrowse** and **wtkMergePage**. | ||
- | < | + | < |
<?php | <?php | ||
$gloLoginRequired = false; | $gloLoginRequired = false; | ||
Line 21: | Line 21: | ||
This assumes you have `UID`, `id` or `GUID` in your SQL query because that value will be passed to the Edit or Delete page for determining which row to affect. | This assumes you have `UID`, `id` or `GUID` in your SQL query because that value will be passed to the Edit or Delete page for determining which row to affect. | ||
- | < | + | < |
SELECT `pet_id` AS `UID`, `pet_name` | SELECT `pet_id` AS `UID`, `pet_name` | ||
FROM `pets` | FROM `pets` | ||
Line 30: | Line 30: | ||
With the WTK library, usually the Add page uses the same PHP page as the Edit page. So although you can have the Add button go anywhere, most of the time you will define them as such: | With the WTK library, usually the Add page uses the same PHP page as the Edit page. So although you can have the Add button go anywhere, most of the time you will define them as such: | ||
- | < | + | < |
$gloEditPage = '/ | $gloEditPage = '/ | ||
$gloAddPage | $gloAddPage | ||
Line 41: | Line 41: | ||
For example, in the `pets` demo table we use the `DelDate` logic so the delete functionality is defined as: | For example, in the `pets` demo table we use the `DelDate` logic so the delete functionality is defined as: | ||
- | < | + | < |
$gloDelPage = ' | $gloDelPage = ' | ||
</ | </ | ||
Line 51: | Line 51: | ||
These extra buttons will be put to the between the Edit button and the Delete button. | These extra buttons will be put to the between the Edit button and the Delete button. | ||
- | < | + | < |
$gloMoreButtons = array( | $gloMoreButtons = array( | ||
'User Logins' | 'User Logins' | ||
Line 74: | Line 74: | ||
In the above example, the 'User Logins' | In the above example, the 'User Logins' | ||
- | < | + | < |
<a onclick=" | <a onclick=" | ||
| | ||
Line 90: | Line 90: | ||
For example, if you only wanted to allow wtkUsers with a SecurityLevel of 80 to be allowed to edit, you would add these two lines before the call to **wtkBuildDataBrowse**. | For example, if you only wanted to allow wtkUsers with a SecurityLevel of 80 to be allowed to edit, you would add these two lines before the call to **wtkBuildDataBrowse**. | ||
- | < | + | < |
$gloEditCondCol | $gloEditCondCol | ||
$gloEditCondition | $gloEditCondition | ||
Line 97: | Line 97: | ||
Likewise, you can set a condition on Delete button displaying by setting the following PHP variables. | Likewise, you can set a condition on Delete button displaying by setting the following PHP variables. | ||
- | < | + | < |
$gloDelCondCol | $gloDelCondCol | ||
$gloDelCondition | $gloDelCondition | ||
Line 106: | Line 106: | ||
If the page is in printing mode or the data is being exported, then the Add, Edit and Delete buttons will not be displayed. | If the page is in printing mode or the data is being exported, then the Add, Edit and Delete buttons will not be displayed. | ||
- | < | + | < |
$gloPrinting = true; | $gloPrinting = true; | ||
</ | </ | ||
Line 113: | Line 113: | ||
All columns will be left justified by default. | All columns will be left justified by default. | ||
- | < | + | < |
$gloColumnAlignArray = array ( | $gloColumnAlignArray = array ( | ||
' | ' | ||
Line 124: | Line 124: | ||
Choosing which columns should be summed is easy also. This only sums the values shown in the list. So if your list is for 200 and your page navigation is set to 50, it will only show the first 50 rows and the total for the rows which are visible. | Choosing which columns should be summed is easy also. This only sums the values shown in the list. So if your list is for 200 and your page navigation is set to 50, it will only show the first 50 rows and the total for the rows which are visible. | ||
- | < | + | < |
$gloTotalArray = array ( | $gloTotalArray = array ( | ||
' | ' | ||
Line 133: | Line 133: | ||
Passing SUM tallies the numbers. | Passing SUM tallies the numbers. | ||
- | < | + | < |
$gloPHPLocale = ' | $gloPHPLocale = ' | ||
$gloCurrencyCode = ' | $gloCurrencyCode = ' | ||
Line 167: | Line 167: | ||
Here is an example SQL query and the associated Sort Options. | Here is an example SQL query and the associated Sort Options. | ||
- | < | + | < |
SELECT p.`UID`, u.`FirstName` AS `Owner`, p.`PetName`, | SELECT p.`UID`, u.`FirstName` AS `Owner`, p.`PetName`, | ||
DATE_FORMAT(p.`BirthDate`,' | DATE_FORMAT(p.`BirthDate`,' | ||
Line 183: | Line 183: | ||
So for the above example, in the PHP you would simply add this before the wtkBuildDataBrowse call. | So for the above example, in the PHP you would simply add this before the wtkBuildDataBrowse call. | ||
- | < | + | < |
wtkSetHeaderSort(' | wtkSetHeaderSort(' | ||
wtkSetHeaderSort(' | wtkSetHeaderSort(' | ||
Line 194: | Line 194: | ||
By default when you have your unique identifying column (UID, GUID, ID) in the SELECT statement, it will not be shown. | By default when you have your unique identifying column (UID, GUID, ID) in the SELECT statement, it will not be shown. | ||
- | < | + | < |
$gloHideUID = false; | $gloHideUID = false; | ||
</ | </ | ||
Line 202: | Line 202: | ||
By default your result set will not be truncated. | By default your result set will not be truncated. | ||
- | < | + | < |
$gloBrowseTruncate = true; | $gloBrowseTruncate = true; | ||
</ | </ | ||
Line 210: | Line 210: | ||
You can set the follow variable and any HTML formatting will be removed from the SQL results before putting them into the browse list. This uses the **wtkRemoveStyle** function which is defined in wtk/ | You can set the follow variable and any HTML formatting will be removed from the SQL results before putting them into the browse list. This uses the **wtkRemoveStyle** function which is defined in wtk/ | ||
- | < | + | < |
$gloBrowseNoStyle = true; | $gloBrowseNoStyle = true; | ||
</ | </ | ||
Line 218: | Line 218: | ||
If you want the SQL results to have <br> added in place of line breaks, set this PHP variable to true before calling **wtkBuildDataBrowse**: | If you want the SQL results to have <br> added in place of line breaks, set this PHP variable to true before calling **wtkBuildDataBrowse**: | ||
- | < | + | < |
$gloBrowseNL2BR = true; | $gloBrowseNL2BR = true; | ||
</ | </ |
browse_box.txt · Last modified: 2024/12/02 04:14 by wtkadmin