How to remove content limit from grid column.i have long text to display it in grid but when display it subtract the string.i want to show full text in the grid.
Ok Found solution just add string_limit in addcolumn or addColumnAfter function in grid.php
$this->addColumnAfter('addons', array(
'header' => Mage::helper('sales')->__('Addons'),
'filter' => false,
'sortable' => false,
'index' => 'addons',
'type' => 'text',
'string_limit' => '500', /* added for content limit */
), 'billing_name');
Related
I did added one editable field in my custom module grid.it display textbox but when i tick the checkbox and change the textbox value i can't get it in post data.
admin grid form code
$this->addColumn('banner_position', array(
'header' => Mage::helper('banner')->__('Position'),
'align' =>'left',
'index' => 'banner_position',
'editable' => true,
'edit_only' => true,
));
Screenshot
Can anyone please guide me on this
I have following code in my Form.php
$fieldset->addField('desc', 'textarea', array(
'label' => Mage::helper('module')->__('Description'),
'required' => true,
'name' => 'desc',
));
How to restrict the number of characters in this text area?
In theory you should be able to do that by adding to the textarea a maxlength attribute.
So you should end up with something like this:
<textarea maxlength="50"></textarea>
But Magento does not allow the maxlength attribute.
If you take a look at the Varien_Data_Form_Element_Textarea class (the one responsable for rendering textareas) you will see this method.
public function getHtmlAttributes()
{
return array('title', 'class', 'style', 'onclick', 'onchange', 'rows', 'cols', 'readonly', 'disabled', 'onkeyup', 'tabindex');
}
Those are the only ones that you can specify when you create the element.
First option would be to extend this class and add the maxlength among the allowed attributes, then your column could look like this:
$fieldset->addField('desc', 'textarea', array(
'label' => Mage::helper('module')->__('Description'),
'required' => true,
'name' => 'desc',
'maxlength' => 50
));
The second option is to add it via some javascript.
$fieldset->addField('desc', 'textarea', array(
'label' => Mage::helper('module')->__('Description'),
'required' => true,
'name' => 'desc',
'after_element_html' => '<script type="text/javascript">Event.observe(window, "load", function() {$("id_of_textarea_here").setAttribute("maxlength", 50)})</script>'
));
A third option would be to insert instead of the javascript above some code that limits the length of the text.
You can find an example here.
Final Note:
the content from after_element_html will be displayed in the form right after the element. So you can basically put anything there.
In magento admin I can only see up to 50 characters of review text. How can I edit template etc so I can view the whole review text?
Thanks
you need to override the _prepareColumns() function under Mage_Adminhtml_Block_Review_Grid
there is below code section
$this->addColumn('detail', array(
'header' => Mage::helper('review')->__('Review'),
'align' => 'left',
'index' => 'detail',
'filter_index' => 'rdt.detail',
'type' => 'text',
'truncate' => 50,
'nl2br' => true,
'escape' => true,
));
in which truncate is used, you need to increase the limit.
I created new magento grid for customer module for special purpose.
In that there have a column usertype it have value as 0,1,2.
It will displayed in customer grid page as 0,1,2.
But i need to display if value is,
0 -> Inactive
1 -> Activated
2 -> Baned
How can i dothis?
This is my code grid.php in _prepareColumns() :
$this->addColumn('usertype', array(
'header' => Mage::helper('customer')->__('Usertype'),
'width' => '150',
'index' => 'usertype'
));
If this is possible in magento.
if your greed implements Mage_Adminhtml_Block_Widget_Grid I suggest you to modify
you addColumn call to
$this->addColumn('usertype',
array(
'header'=> Mage::helper('customer')->__('Usertype'),
'width' => '150px',
'index' => 'usertype',
'type' => 'options',
'options' => $values
));
Where $values should be formatted as
array( 'value_id' => 'value_label')
Now you have dropdown created with values.
Then update _prepareCollection() function and add attribute values to customer grid collection
$collection->joinAttribute('usertype', 'customer/usertype', 'entity_id', null, 'left');
I got the solution from this
By using rendere will help to load vlaues to each row.
I'm trying to write a custom action to run off of an admin grid that I have built. Is it possible to send a value from a column in the grid to the controller via either get or post?
I've tried googling, but I cannot find a proper explanation for this anywhere. A link to an explanation of the column settings ('getter', 'type' etc.) would also be useful if this is available.
Add this code to your Grid.php:
$this->addColumn('action',
array(
'header' => Mage::helper('yourmodulename')->__('Action'),
'width' => '100',
'type' => 'action',
'getter' => 'getId',
'actions' => array(
array(
'caption' => Mage::helper('yourmodulename')->__('Edit'),
'url' => array('base'=> '*/*/edit'),
'field' => 'id'
)
),
'filter' => false,
'sortable' => false,
'index' => 'stores',
'is_system' => true,
));
That will build an "Edit" URL with the Id of the selected row as part of the URL. It will look something like <frontname>/<controllername>/edit/id/<value> where value is returned by the getter getId().
The getter field will execute any of the standard Magento magic getters, ie any attribute is gettable. So you could have getName or getProductUrl or getIsLeftHanded if you wanted and your controller can parse the attribute.
The controller can then retrieve that passed value using Mage::app()->getRequest()->getParam('attributename');
In terms of documentation/tutorials, have a read of this article on the website of #AlanStorm as it might help.
HTH,
JD