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
          主站蜘蛛池模板: 蒙阴县| 深水埗区| 印江| 东至县| 浙江省| 新津县| 肇州县| 吴旗县| 海盐县| 新昌县| 吴江市| 靖宇县| 彩票| 靖远县| 恭城| 互助| 灵山县| 莒南县| 方山县| 威宁| 从化市| 五莲县| 门源| 德阳市| 襄汾县| 永州市| 娄烦县| 资溪县| 化隆| 龙海市| 东城区| 永康市| 崇阳县| 洪雅县| 武乡县| 黑山县| 九台市| 肃宁县| 海兴县| 布尔津县| 班玛县|