Actions on drop down list.

180 views
Skip to first unread message

Srinivasa Rao

unread,
Dec 12, 2012, 5:57:34 AM12/12/12
to joomla-de...@googlegroups.com
Hello All,
 
             i am working on drop down functionality in joomla component.Can anyone explain how to perform actions on drop down list items.
 
Thanks,
Srinu.

sasi varnakumar

unread,
Dec 12, 2012, 8:28:10 AM12/12/12
to joomla-de...@googlegroups.com
Hello Sri,
    Can you be specific? What really you want to know?
How to create a drop down list in joomla component or how to apply some functions like on click over the drop box ??
--
Regards
Sasi varna kumar,
Lead developer - J2Store


--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/pAPzt6zddsEJ.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.



--
  keep smiling ..!! 
S.Sasi varna kumar ( 9952661702 )
Facebook  ||  Twitter  ||  Wordpress


Srinivasa Rao

unread,
Dec 12, 2012, 1:17:45 PM12/12/12
to joomla-de...@googlegroups.com
 Hello sasi,

             Actually i am working on com_book component.In that component i have two tables books and pages table.In books table i
 have book details(name,description,etc) and pages table i have book_id,page_name,page_description etc.In pages view i have page table details and i am putting one drop down menu in pages view.In that drop down menu i retrieve book name using select query.So when i selecting book name in drop down menu then it refreshes and showing corresponding book pages.

       So how will i perform actions on drop down menu items and i am taking onchange event function.

Thanks,
Srinu.

Srinivasa Rao

unread,
Dec 13, 2012, 12:45:40 AM12/13/12
to joomla-de...@googlegroups.com
 Hello Sasi,
 
                   I want to apply some functions like onchange or onclick over the drop down box.and then how to retrieve database values using that functions.
 
Thanks,
Srinu. 

fizzkid

unread,
Dec 13, 2012, 2:57:57 AM12/13/12
to joomla-de...@googlegroups.com
You require AJAX for that. otherwise just form actions

Op donderdag 13 december 2012 06:45:40 UTC+1 schreef Srinivasa Rao het volgende:

Srinivasa Rao

unread,
Dec 13, 2012, 3:05:27 AM12/13/12
to joomla-de...@googlegroups.com
 Hello fizzkid,
                   I am fully confused with that functionality,can u plz provide any source for that.I am trying since two days for that functionality.
 
Thanks,
Srinu. 

sasi varnakumar

unread,
Dec 13, 2012, 3:20:29 AM12/13/12
to joomla-de...@googlegroups.com
Hello Srini,
      Its quite simple, you are speaking about the term "Filter", in your pages view you need to filter them by books.
A similar case: In article manager we have drop down for categories (that is category filter) a dropdown for state (published,unpublish,trash.. that is state filter)

Likewise you need a custom filter for filtering the pages result by book name selected.
Its all version specific in joomla.

What version of joomla u r using/building for?
Where you are building this pages view? In frontend(site) or backend  (Admin)?

i will tell u what to do where based on your answers, you really no need ajax for this its actually the joomla way we need to do that...!

Best Regards
Sasi varna kumar
Lead developer - J2Store


 
Thanks,
Srinu. 

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.

fizzkid

unread,
Dec 13, 2012, 3:22:37 AM12/13/12
to joomla-de...@googlegroups.com
Well to be honest that is a rather broad topic (whole books about it). AJAX allows to interact with the server without having to refresh the page. If that is what you are looking for you might want to have a look in to jquery ajax (google it)
have a read here: http://www.noupe.com/ajax/how-ajax-works.html


Op donderdag 13 december 2012 09:05:27 UTC+1 schreef Srinivasa Rao het volgende:

Srinivasa Rao

unread,
Dec 13, 2012, 3:48:53 AM12/13/12
to joomla-de...@googlegroups.com
Hello Sasi,
 
              I am using joomla version 3.0 and building at backend,i really confused with that functionality,can u plz provide any example for that.

Thanks
    Srinu.

sasi varnakumar

unread,
Dec 13, 2012, 1:04:27 PM12/13/12
to joomla-de...@googlegroups.com
Sure,

There are four things/places you need to do/edit,
1. Pages- view.html.php
      Refer joomla's default component com_weblinks for reference.
      There in the sidebar you need to add a custom filter.


***************************************************
JHtmlSidebar::setAction('index.php?option=com_book&view=pages');
 
        JHtmlSidebar::addFilter(
                
        //get list of countries options  from the model
        $country_options = $this->get('CountriesOptions');
 
        JHtmlSidebar::addFilter(
                JText::_('SELECT_COUNTRY'),
                'filter_country_options',
                JHtml::_('select.options', $country_options, 'value', 'text', $this->state->get('filter.country_options'), true)
        );
***************************************************

In the pages model,

2.  getCountriesOptions() where you told you already done a select query and did that

********************************************************
    public function getCountriesOptions(){
        // Create a new query object.
            $db        = $this->getDbo();
            $query    = $db->getQuery(true);
            $query->select('a.country_id,a.country_name');
            $query->from('#__ppinvoice_countries AS a');       
            $query->where('state = 1');
            $query->order('a.country_name');
            $db->setQuery($query);
            $countries = $db->loadObjectList();
           
            $country_options = array();
            foreach($countries as $item) {
                $country_options[] =  JHTML::_('select.option', $item->country_id, $item->country_name);
            }
           
            return $country_options;
        }
********************************************************


3.  function populateState(){}
    you need to add two lines
 ***************************************************
$type = $app->getUserStateFromRequest($this->context.'.filter.country_type', 'filter_country_type', '', 'string');
 $this->setState('filter.country_type', $type);
       
***************************************************
4. And the last one, in the same model file in getListQuery function you need to add another where clause or where query to that, which will filter the result.

***************************************************
// Filter by Country.
        $country = $this->getState('filter.country_options');
        if ($country) {
            $query->where('a.country_id = '.$db->quote($country));
        }
       
***************************************************

I hope this helps.

Best regards

Sasi varna kumar
Lead developer - J2Store
Reply all
Reply to author
Forward
0 new messages