0

dwr 呼び出しは、任意の数の特定の列を持つ一連のデータを返します。たとえば、名前、ID、住所などです。アドレスは、最初のレコードの場合は address1、address2、2 番目のデータの場合は address1、address2、address3 のように、1、2、または 3 になります。私の質問は、jqgrid の列名を動的にする方法です。

DataHandler.fetch(function(data){
resultSet = data;
jQuery("#table1").jqGrid({
datatype : "local",
  data : resultSet,
  height : 250,
  width : 978,
  sortable : false,
  ignoreCase : true,
  sortorder : "desc",
  colNames : ['Email Date/Time','User Name', 'Department'] //want to make this dynamic
    colModel : [ {
   name : 'mailedOn',
    index : 'mailedOn',
    width : '18%',
    align : 'center',
     }, {
    name : 'userName',
 index : 'userName',
 width : '18%',
  align : 'left',   
  sorttype : 'text',
}],
        rowList:[10,20,30],
       pager : '#pager',
       rowNum : 10,
      altRows : true,
       altclass: "myclass",
     viewrecords : true
       }); 
     });

何か助けて??

4

1 に答える 1

0

修正された (既知の) 列数があり、列ヘッダーを動的に変更 (変更) する必要がある場合は、回答colNamesから解決策を読み、 demoを試すことをお勧めします。質問は「重複」としてマークされており、私の回答には現在投票がないため、検索中に回答を見つけることができません。

私の提案の主なアイデアは、 などの一般的な列名を使用しc1c2の中で列ヘッダーを動的に変更することですbeforeProcessing。同じように、colModel(set formatter、など)の項目のプロパティを変更することもできますが、現在これを行う必要はないようです。formatoptionseditoptions

于 2013-06-10T14:56:32.847 に答える