dongzhanlu0658 2012-02-25 02:05
浏览 42

如何在数据中标记网格中的复选框?

I know how to select some rows from a grid as indicated here: http://agiletoolkit.org/blog/how-to-select-elements-in-a-grid/

But I want to do the opposite, I want to have a grid, with selectable column, where I want to have checked the rows with certain ids from database, and then be able to unselect some or select a new one.

Is there a "prefered" method to do that in Agile Toolkit?

  • 写回答

1条回答 默认 最新

  • dongyuan9892 2012-02-26 17:09
    关注

    i'll make this short just to answer the question.

    to preselect checkboxes on Grid Basic or MVC Grid, you just need to fill-in the values in the accompanying Form's selected Form_Field, example:

     class page_gridcheckboxestest extends Page {
        function init() {
           parent::init();
    
           $g = $this->add('MVCGrid');
           $g->setModel('Employees');
    
           $f = $this->add('Form');
           $f->addField('hidden','selected');
    
           $preselect = array(1,2,3,4,5); // array of preselected ids
           $f->getElement('selected')->set(json_encode($preselect));
    
           $g->addSelectable($f->getElement('selected'));
        }
     }
    

    the array of preselected ids has to be in JSON format for this to work.

    评论

报告相同问题?

悬赏问题

  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输