2013-11-27 38 views
0

我想在編輯/添加模式下將多個複選框添加到列。現在這個列有一個啓用了多個選項的選擇框。我想用複選框列表或單選按鈕列表替換它jqGrid如何將多個複選框添加到列

我的想法是:用戶應該能夠通過選中特定單元格中列出的複選框來選擇相關選項(在添加或編輯模式下:一致)。保存行後,只應顯示選定的用戶選項(不帶複選框)。

下面是我爲特定列選擇框代碼片段:

{ 
    name: 'RoomTypes', index: 'RoomTypes', width: 300, editable: true, edittype: 'select', 
        editoptions: { 
         value: roomTypesFormatterEdit, 
         custom_element: function (value, options) { 
          return $.jgrid.createEl.call(this, "select", 
           $.extend(true, {}, options, { custom_element: null, custom_value: null }), 
           value); 
         }, 
         custom_value: function ($elem, operation, value) { 
          if (operation === "get") { 
           return $elem.val(); 
          } 
         }, 
         multiple: true 
        }, 
        align: 'left', formatter: roomTypesFormatter 
       }, 

如果酒店房間的名稱將在選擇框中顯示的「roomTypesFormatterEdit」返回列表。

此外,我想重新安排行的編輯(編輯模式)的高度以適合的複選框的高度或顯示在選擇框中的所有項目

請幫助 謝謝大家

回答

2

我認爲你不需要編寫自定義編輯控件(custom_elementcustom_value)或自定義格式(formatterunformat)。取而代之的是,您只需將multiple: true屬性添加到editoptions即可擁有基本多選功能。爲了提高可視性,您可以使用一些現有控件,如jQuery UI MultiSelect WidgetSelect2The answerthis one提供了使用jQuery UI MultiSelect Widget的演示。 One more answerthis one提供了使用Select2的演示。演示程序不使用Select2的多選功能,但它只是控件的一個選項(請參閱the documentation)。

+0

感謝您的回覆Oleg。我會試試這個,讓你知道狀態! – gamini2006

+0

@ gamini2006:不客氣! – Oleg

+0

它很棒!你的男人奧列格,再次感謝.... – gamini2006

相關問題