How to add filter form to magento admin grid? - forms

How to add a filter form as like report->sales->orders to my custom module. The filtered result should be shown in grid table.I have made the data to be displayed in the grid.

In Grid.php, where you are creating columns of grid, you need to add 'filter'=>true. Like below:
$this->addColumn('COLUMN_NAME', array(
'header' => Mage::helper('MODULE_NAME')->__('COLUMN_HEADER_TEXT'),
'index' => 'COLUMN_NAME',
'sortable' => true, // make sortable column
'filter' => true // make filter column
));
Hope will help!

Related

TYPO3 10.4: How can you add another dropdown field to the appearance tab of an content element?

I want to add more dropdown fields to the appearance tab for editing content elements.
How can I achieve this?
I've tried to add more layouts for the pageTs but that doesn't work. Also couldn't find more on this on the internet.
You can't do this via the backend. You will need to extend the TCA (e.g. in your sitepackage extension).
In your extension:
Add the field in ext_tables.sql
Extend the TCA in Configuration/TCA/Overrides/tt_content.php:
add new fields to the columns
Add the new fields to the visible fields
Add the new fields to the appropriate palette
Tip: You can look at the active TCA configuration for tt_content in the TYPO3 backend Configuration | Globals['TCA']
If you want to place the new field after an existing field, e.g. space_before_class, check which palette this is in ('frames') and place it in that.
Example:
ext_tables.sql:
CREATE TABLE tt_content(
my_new_field TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL
);
Configuration/TCA/Overrides/tt_content.php
$fields = [
// new field
'my_new_field' => [
// title of the field
// alternatively, just use a string, but putting the string in
// language file eases translations
'label' => 'LLL:EXT:myextension/Resources/Private/Language/locallang.xlf:tt_content.my_new_field.title',
'config' => [
// type: select
'type' => 'select',
'renderType' => 'selectSingle',
'default' => 0,
'items' => [
[
// again, better to use language label LLL here
'description',
// value
0
],
[
// another option
'description 2',
// value
1
],
],
],
],
// ...
];
// Add new fields to table:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content', $fields);
// Add new field to palette 'frames'
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette(
'tt_content',
'frames',
'my_new_field',
'before:frame_class'
);
Resources:
extend TCA: https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/HowTo/ExtendingTca/Examples/Index.html
TCA: columns field types: https://docs.typo3.org/m/typo3/reference-tca/main/en-us/ColumnsConfig/Index.html
select types: https://docs.typo3.org/m/typo3/reference-tca/main/en-us/ColumnsConfig/Type/Select/Index.html
For the rest of the options, refer to the TCA Reference: https://docs.typo3.org/m/typo3/reference-tca/main/en-us/Index.html
If you could live just with more options to the given fields you can do it in the BE without programming / extending the TCA (Sybille's answer).
Extending the given list of select options for the existing fields is possible with some page/user TSConfig like:
TCEFORM.tt_content.layout.addItems {
20 = additional layout 1|nyt layout 1|neues Layout 1|...
25 = additional layout 2|nyt layout 2|neues Layout 2|...
}
TCEFORM.tt_content.frame_class.addItems {
50 = frame-class-50
55 = frame-class-55
}
Of cause this needs a handling in the rendering of the CEs.
Depending on the TYPO3 version and the active rendering there are different places to handle this.
Without FLUID rendering it needs some edits in the typoscript, with FLUID you need to override the appropriate file (layout/template/partial) where the field (here: layout and frame_class) is handled.

How to always have a blank placeholder row for new records in AG Grid?

How do I set up AG Grid such that there is always a blank placeholder row at the bottom for new records? So that it behaves like Excel, or like Slickgrid when enableAddRow is true.
When passing the rowData array to the grid component, you can include an extra object with blank values.
For example, if you had a grid of Employee objects with attributes name and title, the following would work with ES6:
rowData=[ ...existingEmployees, { name: '', title: '' } ]

set row grouping programatically in ag-grid

I tried setting rowGrouping to a specific column as shown below:
columnDefs[index]["rowGroup"] = true;
this.setState({ columnDefs: columnDefs });
params.api.setColumnDefs(columnDefs);
The grid is getting rerendered but the row grouping is not getting set. Is there any other ag-grid api to set the row groups manually(just like columnApi.setColumnVisible to hide/show a specific column).
Looks like your updated columnDefs is not being applied to the grid.
Setting your columnDef to an empty array or creating a new ColumnDef object altogether should solve this.
gridOptions.api.setColumnDefs([]);
gridOptions.api.setColumnDefs(newColDefs);

ag-grid autoSizeColumns only uses header and not rows content for resizing columns

I'm trying to auto resize each column to match the length of the columns content.
This is my code:
<AgGridReact
onFirstDataRendered={(p) => {
p.columnApi.autoSizeColumns(p.columnApi.getAllColumns());
}}
floatingFilter={true}
defaultColDef={{
sortable: true,
}}
enableColResize
columnDefs={data.columnDefs}
rowData={rowData}
/>
This is the result:
If I add true in this line, which is to skipHeader:
p.columnApi.autoSizeColumns(p.columnApi.getAllColumns(), true);
the result is this:
How can I fix this?
Looking at the limited code, unless it is a timing issue, the following should solve it -
const allColumnIds = p.columnApi.getAllColumns().map((column) => column.colId);
p.columnApi.autoSizeColumns(allColumnIds);
Try passing column ids to autoSizeColumns

A checkbox data type and showing more than one row per "row" (in Adazzle react-data-grid)

We'd like to use React Data Grid from Adazzle (as mentioned in the tag with this question) now that we're using React (16.xx) and the older jsGrid is less appealing.
Two questions:
Our old jsGrid had a data type to include in the grid called Checkbox. This was immensely helpful. I haven't found a similar type in the React Grid. Have I just missed it or is it not a part of the library?
In each row, in some columns, we'd like to actually have two rows of data inside the column -- i.e., two lines of text separated by carriage return. But the react-data-grid demos only seem to show one line per column. Is this a limitation, or can we use CSS in the values inside columns?
Is there search included for the rows shown in the table at any given point in time?
I will provide answer to your question part by part
1) In react-data-grid column you can include a checkbox by using the formatter
attribute that is specified while the columns are defined.
Consider the following example
let columns = [
{
key: 'name',
name: 'Name',
resizable: true,
width: 100
},
{
key: 'checkbox',
name: 'CheckBox',
formatter:checkBoxFormatter,
resizable: true,
width: 100
}
]
class checkBoxFormatter extends React.Component {
render() {
return (
<div>
<CheckBox></Checkbox> //Provide your checkbox code here
</div>
)
}
}
2)You can exapand the rows for that you need to use getSubRowDetails and onCellExpand attributes of ReactDataGrid component .For example refer this documentation
3)Search is available for filtering .For example refer this documentation