Sealyu

          --- 博客已遷移至: http://www.sealyu.com/blog

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            618 隨筆 :: 87 文章 :: 225 評論 :: 0 Trackbacks
          • Approach 1
            • Use the array grid example in your packaged download array-grid.js
            • Add an extra column to the column model definition and a custom renderer.
          {header: "Controls", 

          width: 60,

          sortable: false,

          renderer: function() {

          return '<div class="controlBtn">

          <img src="../shared/icons/fam/cog_edit.png"

          width="16" height="16"

          class="control_edit">

          <img src="../shared/icons/fam/folder_go.png"

          width="16" height="16"

          class="control_go"></div>';

          },

          dataIndex: 'company'}
            • Then you would setup an event handler on the click event.
          grid.on('click', function(e) {

          var btn = e.getTarget('.controlBtn');

          if (btn) {

          var t = e.getTarget();

          var v = this.getView();

          var rowIdx = v.findRowIndex(t);

          var record = this.getStore().getAt(rowIdx);

          var control = t.className.split('_')[1];

          switch (control) {

          case 'edit':

          console.log('edit this record - ' + record.id);

          break;

          case 'go':

          console.log('go to this record - ' + record.id);

          break;

          }

          }

          }, grid);
            • Add the following CSS rule in array-grid.html to give some padding and change the cursor.
          <style>

          .controlBtn img {

          padding-left: 4px;

          cursor: pointer;

          }

          </style>
            • Using this same method you could add as many tools as you would like in the controls section and always give them the css class "controls_{toolname}". Ideally you would break this out into an XTemplate so that you could simply pass in whatever tools you would like to use and output them on the grid as well.

          • Approach 2 utilizes a plugin as discussed here  :
          http://rowactions.extjs.eu/
          posted on 2009-11-30 14:57 seal 閱讀(331) 評論(0)  編輯  收藏 所屬分類: EXTJS
          主站蜘蛛池模板: 建宁县| 泰和县| 金平| 廊坊市| 和静县| 江阴市| 纳雍县| 都兰县| 朝阳区| 广灵县| 利辛县| 合江县| 肥城市| 郓城县| 正阳县| 乐昌市| 海口市| 成武县| 正镶白旗| 西峡县| 明水县| 湟中县| 百色市| 临江市| 彰化县| 新丰县| 阿鲁科尔沁旗| 安仁县| 通辽市| 叙永县| 津南区| 政和县| 吴忠市| 汉沽区| 寻乌县| 贺州市| 临沧市| 泸州市| 遂溪县| 当涂县| 台前县|