Results 1 to 4 of 4

Thread: loading accordion dynamically from database

  1. #1
    Ext User
    Join Date
    Jan 2009
    Posts
    39

    Default loading accordion dynamically from database

    hi,
    i'm newbies in extjs and to load my accordion dynamically from a database
    Someone have an idea how to do it?
    thanks

  2. #2
    Sencha Premium Member steffenk's Avatar
    Join Date
    Jul 2007
    Location
    Haan, Germany
    Posts
    2,676

    Default

    what do you mean, the content?

    Try to build a simple accordion first to see how it works. You have a normal HTML markup with content and transform it to an accordion.
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5

  3. #3
    Ext User
    Join Date
    Jan 2009
    Posts
    39

    Default

    hi,
    i mean items of accordion

  4. #4
    Ext User Stripeman's Avatar
    Join Date
    Apr 2008
    Location
    Heidelberg Germany
    Posts
    275

    Default

    Your question is pretty plain Jane... is your question more like how do I add items to a an accoridan panel dynamically ? if so... this is how i did it...

    On your PHP (constant include) page you can do something like this...
    PHP Code:
    <?php

                            $_SESSION
    ['Roles']     = @str_split($obj->Roles,1);    //Permission Array
                            
    if (@$_SESSION['Roles']) {

                                
    $permarray $_SESSION['Roles'];  
                                
                                
    // Run through each permissions (contained in array) and bulid the permission ledgend
                                
    $perms='';
                                for (
    $i=0$i <= count($permarray); $i++) {
                                   
    $eaPerm $permarray[$i];
                                   switch (
    $eaPerm)    {
                                       case 
    'A':
                                           
    $eaPerm "A: Admin";
                                           
    ?>  permsAdmin = true; <?php           //set the JS var to unhide menu items 
                                           
    break;
                                       case 
    'M':
                                           
    $eaPerm "M: Member";
                                           
    ?>  permsMember = true; <?php       //set the JS var to unhide menu items
                                           
    break;
                                       case 
    'S':
                                           
    $eaPerm "S: Super/DB Admin";
                                           
    ?>  permsSuperAdmin = true; <?php   //set the JS var to unhide menu items
                                           
    break;        
                                       case 
    'O':
                                           
    $eaPerm "O: Other";
                                           
    ?>  permsOther = true; <?php          //set the JS var to unhide menu items
                                           
    break;
                                   
                                   }                               
                                   
    $perms .=  $eaPerm.'<br>';
                                }
                            }
                                                        
                            
    ?>

    Then .. in your JS for your accordion:
    PHP Code:
                      if (permsSuperAdmin){                                 // User is Super/DB Admin
                         
    addWestMenuItems.add({             
                                
    cls'west-panel-content',
                             
    title:'DB Admin',
                             
    autoHeighttrue,
                             
    id'acc_genDBAdmin',
                             
    showPin:true,
                             
    stateId:'acc_genDBAdmin'
                             
    border:false,
                             
    iconCls:'settings',
                             
    bodyStyle'background-color:#FFE680;',
                             
    xtype'treepanel',
                                  
    dataUrl'get_nav.php?getNav=genDBAdmin',
                                  
    root: new Ext.tree.AsyncTreeNode({
                                  
    expandedtrue,
                                  
    text'Administrative DB Functions',                                
                                  
    id'id_siteDBAdmin',
                                  
    qtip'Site DB Administrative Functions'
                            
    })                                 
                         });
                       }   
    // End Check if user is Super/DB Admin 
    in my "get_nav.php?getNav=genDBAdmin"

    I have this code to actually build the items in the accordian ( i have one for each accordian) and its contents are restrictive based on permissions (from db) - see session loop at top:
    PHP Code:
            if(($getNav == 'genDBAdmin') && (in_array("A",$_SESSION['Roles']))){   //IS "A"dmin function
                
    $string_getNav .= "
                {
                    text: 'New (all)',
                    url : '?page=adminViewAllUsers',
                    leaf: true,
                       qtip: 'View all Users'
                },"
    ;
                
                
                
    $string_getNav .= "
                {
                    id: 'id_jobPositions',
                    text: 'Positions',
                    href : '?page=adminPositions',
                    leaf: true,
                    qtip: 'Add/Remove positions'
                },"
    ;            
            }  
    // END  $getNav == 'genDBAdmin' 

    Hope that helps and is what your looking for... an example with this capability should be added as an Ext sample/example. Not saying that this is good enough to be an example we should use, but something simular

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •