select All ------grid控件----magento后台查询所有信息
来源:互联网 发布:java爬虫框架selenium 编辑:程序博客网 时间:2024/05/21 07:08
1
首先写controller
public function kunAction(){
$this->loadLayout();
$this->_addContent($this->getLayout()->createBlock('gao/manage_gao'));
$this->renderLayout();
}
2
编写block
app/code/community/AQ/Gao/Block/Manage/Gao.php
app/code/community/AQ/Gao/Block/Manage/Gao/Grid.php
2.1
app/code/community/AQ/Gao/Block/Manage/Gao.php
<?php
class AQ_Gao_Block_Manage_Gao extends Mage_Adminhtml_Block_Widget_Grid_Container{
public function __construct(){
//生成路径使用
$this->_controller = 'manage_gao';
//模块名字
$this->_blockGroup = 'gao';
//头标题
$this->_headerText = 'Blog Post Manager';
parent::__construct();
}
protected function _prepareLayout(){
$this->setChild('add_new_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData(array(
'label' => 'Add Post',
//按钮按下后执行的路径。
'onclick'=>"setLocation('".$this->getUrl('*/*/new')."') ",
'class' =>'add'
))
);
//多商店情况下。
if (!Mage::app()->isSingleStoreMode()) {
$this->setChild('store_switcher',
$this->getLayout()->createBlock('adminhtml/store_switcher')
->setUseConfirm(false)
->setSwitchUrl($this->getUrl('*/*/*', array('store'=>null)))
);
}
//子block指定。这里指定的就是app/code/community/AQ/Gao/Block/Manage/Gao/Grid.php
$this->setChild('grid', $this->getLayout()->createBlock('gao/manage_gao_grid', 'gao.grid'));
return parent::_prepareLayout();
}
}
2.2
app/code/community/AQ/Gao/Block/Manage/Gao/Grid.php
此block为2.1的子block
<?php
class AQ_Gao_Block_Manage_Gao_Grid extends Mage_Adminhtml_Block_Widget_Grid{
public function __construct(){
parent::__construct();
//
$this->setId('gaoGrid');
//按时间排序
$this->setDefaultSort('created_time');
//排序方式
$this->setDefaultDir('DESC');
$this->setSaveParametersInSession(true);
}
protected function _getStore()
{
$storeId = (int) $this->getRequest()->getParam('store', 0);
return Mage::app()->getStore($storeId);
}
protected function _prepareCollection()
{
//数据的加载
$collection = Mage::getModel('blog/blog')->getCollection();
$store = $this->_getStore();
if ($store->getId()) {
$collection->addStoreFilter($store);
}
//
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns(){
$this->addColumn('post_id', array(
'header' => 'ID',
'align' =>'right',
'width' => '50px',
'index' => 'post_id',
));
$this->addColumn('title', array(
'header' => 'Title',
'align' =>'left',
'index' => 'title',
));
//echo "fdfd";
return parent::_prepareColumns();
}
//点击其中的每行访问的路径地址。并指定传出的ID值。
public function getRowUrl($row)
{
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
}
}
- select All ------grid控件----magento后台查询所有信息
- Magento后台Grid删除Add New按钮
- magento 后台订单grid表获取shipping_description
- save-------magento --后台保存信息!!
- magento -- 如何修改后台列表(Grid)的默认行数
- delete-----magento后台数据信息删除----------
- 后台Order grid 显示所有items图片
- edit -------magento后台编辑数据---控件
- magento grid collection 多表查询字段冲突的解决
- Magento Grid collection联表查询添加字段
- magento---后台grid加载过程分析(二)-------edit grid-----news插件为例!
- query ajax json 通过后台代码(查询数据库)绑定html控件select 下拉框实例
- 查询数据库所有表信息
- jsp查询所有图书信息
- 查询所有表的所有字段信息
- Asp.net后台绑定select服务器控件
- Select Html控件后台控制问题
- magento ----后台grid模块的加载 --以news插件为例个人分析(一)
- POJ 3164 Command Network
- 服务器文件同步的方法
- FreeBSD 设置网卡IP,网关和DNS
- VS2005 制作安装程序
- edit -------magento后台编辑数据---控件
- select All ------grid控件----magento后台查询所有信息
- sara Ford
- 生命的奇妙!
- HTML5 Server-Push Technologies, Part 1
- save-------magento --后台保存信息!!
- for循环的简单例子
- How to change upsell product display number on product view page?
- LNMP配置文件及问题解决
- Android-NDK开发之基础--Android JNI开发高级篇(JNI中的常用方法)