JHTMLGrid

From Joomla! Documentation
(Difference between revisions)
Jump to: navigation, search
(Bulk upload by Doxiki2)
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
'''JHTMLGrid class'''
+
This class is available in the following Joomla versions:-
'''methods are following'''
+
<splist showpath=notparent />
sort
+
<noinclude>[[Category:Framework]][[Category:JHTMLGrid]]</noinclude>
id
+
access
+
checkedOut
+
published
+
state
+
order
+
 
+
'''sort'''
+
needed someone to write about this.
+
 
+
'''id method'''
+
This method is used to make checkbox respective to record retrieved from database and displayed to administrator screen. You can use
+
JHTML::_('grid.id',  $i, $row->id )
+
and please don't forget to echo this. Use this with loop of record list retrieved by database.
+
 
+
'''access'''
+
needed someone to write about this.
+
 
+
'''checkedOut'''
+
needed someone to write about this.
+
 
+
'''published'''
+
I recently experienced with this method and would like you tell about this, that how it can be useful for you to show publish/unpublish icon against record displayed on your screen. Please keep in mind its about administrator side, not client side of Joomla.
+
First you needed a hidden input field with form to which you are working with. This should be named check and it has value post, like this
+
 
+
<input type="hidden" name="check" value="post"/>
+
 
+
Then you need this PHP script in column where you want to put this icon
+
 
+
echo $published = JHTML::_('grid.published', $row, $i  );
+
 
+
This will call published method of JHTMLGrid class. It will fire a task named 'publish()' , so you can handle by inserting a function named publish into your controller. Have a look over following
+
+
{
+
 
+
$cid = JRequest::getVar( 'cid', array(), '', 'array' );
+
 
+
$this->publish = ( $this->getTask() == 'publish' ? 1 : 0 );
+
+
JArrayHelper::toInteger($cid);
+
 
+
if (count( $cid ) < 1) {
+
 
+
$action = $publish ? 'publish' : 'unpublish';
+
 
+
JError::raiseError(500, JText::_( 'Select an item to' .$action, true ) );
+
 
+
}
+
 
+
$this->cids = implode( ',', $cid );
+
 
+
+
$query = 'UPDATE #__pricequote'
+
 
+
. ' SET published = ' . (int) $this->publish
+
 
+
. ' WHERE id IN ( '. $this->cids .' )' ;   
+
 
+
$db =& JFactory::getDBO();
+
 
+
$db->setQuery( $query );
+
 
+
if (!$db->query())
+
 
+
{
+
 
+
JError::raiseError(500, $db->getErrorMsg() );
+
 
+
}
+
 
+
$link = 'index.php?option=com_pricequote';
+
 
+
$this->setRedirect($link, "Updated Successfully.");
+
 
+
}
+
 
+
 
+
This is function that will update published field value into table.
+
 
+
That was all I have to write about published method. May be any other can improve this.
+
 
+
'''state'''
+
needed someone to write about this.
+
 
+
'''order'''
+
needed someone to write about this.
+

Latest revision as of 16:28, 17 April 2011

This class is available in the following Joomla versions:-

Personal tools
Namespaces

Variants
Actions
Navigation
Joomla! Sites
Toolbox