| 1 | <?xml version="1.0" encoding="utf-8" standalone="yes" ?> |
|---|
| 2 | <?xml-stylesheet type="text/xsl" href="./modx.prosilver.en.xsl" ?> |
|---|
| 3 | <!-- |
|---|
| 4 | NOTICE: Please open this file in your web browser. If presented with a security warning, you may safely tell it to allow the blocked content. |
|---|
| 5 | --> |
|---|
| 6 | <!--For security purposes, please check: http://www.phpbb.com/mods/ for the latest version of this MOD. Although MODs are checked before being allowed in the MODs Database there is no guarantee that there are no security problems within the MOD. No support will be given for MODs not found within the MODs Database which can be found at http://www.phpbb.com/mods/--> |
|---|
| 7 | <mod xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.phpbb.com/mods/xml/modx-1.2.2.xsd"> |
|---|
| 8 | <header> |
|---|
| 9 | <meta name="generator" content="MODX file generated with PP MODX Creator by tumba25" /> |
|---|
| 10 | <license>MIT</license> |
|---|
| 11 | <title lang="en">Adding filters to meta datagrids</title> |
|---|
| 12 | <description lang="en">Here are the steps you need to perform to make your code-generated QMetaDataGrids have automatic filtering.</description> |
|---|
| 13 | <author-notes lang="en">This will make all generated data grids filtered by default. |
|---|
| 14 | |
|---|
| 15 | You can set FilterShow? to false on the datagrid, in order to hide the filter row, which should make it indistinguishable from a normal QDataGrid. |
|---|
| 16 | |
|---|
| 17 | If you wish to avoid running all the other code, you can do something like: * Add a $blnIsFiltered type property to the MetaDataGrid? class * Add if($this->blnIsFiltered) before the $objNode->SetFilteredDataGridColumnFilter?($objNewColumn); line |
|---|
| 18 | |
|---|
| 19 | Then, if you set your metadatagrid to not filtered before you call MetaAddColumn?, it won't set any filters for the columns</author-notes> |
|---|
| 20 | <author-group> |
|---|
| 21 | <author> |
|---|
| 22 | <realname>Ryan Peters</realname> |
|---|
| 23 | <username>VexedPanda</username> |
|---|
| 24 | </author> |
|---|
| 25 | </author-group> |
|---|
| 26 | <mod-version>1.0.0</mod-version> |
|---|
| 27 | <installation> |
|---|
| 28 | <level>intermediate</level> |
|---|
| 29 | <time>900</time> |
|---|
| 30 | <target-version>1.0.0</target-version> |
|---|
| 31 | </installation> |
|---|
| 32 | <link-group> |
|---|
| 33 | <link type="dependency" href="http://qcodo.com/downloads" lang="en">QFilteredDataGrid</link> |
|---|
| 34 | </link-group> |
|---|
| 35 | </header> |
|---|
| 36 | <action-group> |
|---|
| 37 | <open src="includes/qcodo/_core/framework/QQuery.class.php"> |
|---|
| 38 | <edit> |
|---|
| 39 | <find><![CDATA[class QQNode {]]></find> |
|---|
| 40 | <action type="after-add"><![CDATA[public function SetFilteredDataGridColumnFilter(QFilteredDataGridColumn $col) { |
|---|
| 41 | |
|---|
| 42 | switch($this->strType) { |
|---|
| 43 | case QType::Boolean: |
|---|
| 44 | //List of true / false / any $col->FilterType = QFilterType::ListFilter; $col->FilterAddListItem("True", QQ::Equal($this, true)); $col->FilterAddListItem("False", QQ::Equal($this, false)); $col->FilterAddListItem("Set", QQ::IsNotNull($this)); $col->FilterAddListItem("Unset", QQ::IsNull($this)); break; |
|---|
| 45 | case QType::String: case QType::DateTime: |
|---|
| 46 | //LIKE $col->FilterType = QFilterType::TextFilter; $col->FilterPrefix = '%'; $col->FilterPostfix = '%'; $col->Filter = QQ::Like($this, null); break; |
|---|
| 47 | case QType::Float: case QType::Integer: |
|---|
| 48 | //EQUAL $col->FilterType = QFilterType::TextFilter; $col->Filter = QQ::Equal($this, null); break; |
|---|
| 49 | case QType::Object: case QType::Resource: |
|---|
| 50 | //this node points to a class, there's no way to know what to filter on $col->FilterType = QFilterType::None; $col->ClearFilter(); break; |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | }]]></action> |
|---|
| 54 | </edit> |
|---|
| 55 | </open> |
|---|
| 56 | <open src="includes/qcodo/codegen/templates/db_orm/meta_datagrid/_main.tpl"> |
|---|
| 57 | <edit> |
|---|
| 58 | <find><![CDATA[extends QDataGrid]]></find> |
|---|
| 59 | <action type="replace-with"><![CDATA[extends QFilteredDataGrid]]></action> |
|---|
| 60 | </edit> |
|---|
| 61 | </open> |
|---|
| 62 | <open src="includes/qcodo/codegen/templates/db_orm/meta_datagrid/meta_add_column.tpl"> |
|---|
| 63 | <edit> |
|---|
| 64 | <find><![CDATA[QDataGridColumn]]></find> |
|---|
| 65 | <action type="replace-with"><![CDATA[QFilteredDataGridColumn]]></action> |
|---|
| 66 | <find><![CDATA[The end of if(is_array($mixContent) block]]></find> |
|---|
| 67 | <action type="after-add"><![CDATA[$objNode->SetFilteredDataGridColumnFilter?($objNewColumn); |
|---|
| 68 | ]]></action> |
|---|
| 69 | </edit> |
|---|
| 70 | </open> |
|---|
| 71 | <open src="includes/qcodo/codegen/templates/db_orm/meta_datagrid/meta_data_binder.tpl"> |
|---|
| 72 | <edit> |
|---|
| 73 | <find><![CDATA[CountAll()]]></find> |
|---|
| 74 | <action type="replace-with"><![CDATA[QueryCount($this->Conditions)]]></action> |
|---|
| 75 | <find><![CDATA[LoadAll()]]></find> |
|---|
| 76 | <action type="replace-with"><![CDATA[QueryArray($this->Conditions, $objClauses)]]></action> |
|---|
| 77 | </edit> |
|---|
| 78 | </open> |
|---|
| 79 | </action-group> |
|---|
| 80 | </mod> |
|---|