PDA

View Full Version : Loading different pictures in different tabs



new2extjs
4 Dec 2011, 9:50 AM
I have a tab panel and 2 separate tabs in which I can upload and display pictures. Currently both of them show the same pictures eg if I upload picture in one tab then it is automatically shown in another tab also. How can I make each tab recognise and load only those pictures that are loaded to that tab only?

Thanks

skirtle
4 Dec 2011, 4:19 PM
It sounds like you're sharing something between tabs that you shouldn't be, like a store perhaps, but without any insight into your code it's impossible to be specific.

new2extjs
5 Dec 2011, 10:28 AM
Thanks for the reply.
Yes they are sharing the same database table and I am using server side language PHP to access the data. It's MVC pattern and I am wondering how to make tab content unique on the basis of a field in the table. I am sending url with tabid to controller and it saves it in the database but I am having problem in retrieving the content from the database and showing them in the each of the tabs.
I would be grateful if you can provide some guidance.



url sent from extjs : attachments/gallery?tabid=1?
Inside controller:
public function galleryAction(){
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer('gallery');
$attHelper = $this->_helper->getHelper("attachmentsHelper");
$type= $this->_getParam('type', "");

$tabId= $this->_getParam('tabid', "");
try {
$model = $attHelper->load($type, $tabId);
$array = array();
if (is_array($model)){
foreach($model as $att){

$item = array(
'id' => $att->getId(),
'user_id' => $att->getUserId(),
'description' => $att->getDescription(),

//'tabid' =>$att->getTabId() -this doesn't work and gives an error eventhough value is stored in database
);
$array[] = $item;

}
}


print("tabId".$tabId); // doesn't show value of tab id and doesn't display all the images uploaded in that tab
}

//$json["attachments"] = $array;
$this->view->attachments = $array;

}catch (Exception $e){
}
}

query inside load function:
$select->where('type = ?', $type)
->where('tabid = ?', $tabId);

$rows = $dbtable->fetchAll($select);

skirtle
5 Dec 2011, 5:04 PM
Unless I'm mistaken this appears to be a PHP question, which is outside the scope of this forum. At an ExtJS level you just need to use a different URL for each tab, which it sounds like you are.