2012-08-14 59 views
0

我在jqGrid中有一個子網格,它工作得很好。不過,我想爲onSelectRow添加一個事件,就像我在主網格中一樣。那可能嗎?我的網格定義:在jqGrid中爲子網格行添加事件?

$("#skeppsdagbok_grid").jqGrid({ 
     datatype: 'local', 
     mtype: 'GET', 
     colNames: [ 
       'Datum', 
       'Tid', 
       'Tkn', 
       'Lat', 
       'Tkn', 
       'Long', 
       'Kurs', 
       'Fart', 
       'Anteckning', 
       'Sign', 
       'OK', 
       'Skapad'], 
     colModel: [ 
       { name: 'Datum', sortable: false, width: 70, formatter: 'date' }, 
       { name: 'Tid', sortable: false, width: 65, formatter: 'date', formatoptions: { srcformat: 'H:i:s', newformat: 'ShortTime'} }, 
       { name: 'LatitudTecken', sortable: false, width: 10 }, 
       { name: 'Latitud', sortable: false, width: 50 }, 
       { name: 'LongitudTecken', sortable: false, width: 10 }, 
       { name: 'Longitud', sortable: false, width: 50 }, 
       { name: 'Kurs', sortable: false, width: 50 }, 
       { name: 'Fart', sortable: false, width: 50 }, 
       { name: 'Anteckning', sortable: false, width: 100 }, 
       { name: 'Sign', sortable: false, width: 50 }, 
       { name: 'OK', sortable: false, width: 30, formatter: 'checkbox' }, 
       { name: 'Skapad', sortable: false, width: 100 } 
      ], 
     rowNum: -1, 
     rownumbers: true, 
     ignoreCase: true, 
     viewrecords: true, 
     gridview: true, 
     shrinkToFit: false, 
     width: 750, 
     height: 465, 
     caption: 'Skeppsdagbok', 
     jsonReader: { 
      root: "rows", 
      page: "page", 
      total: "total", 
      records: "records", 
      repeatitems: true, 
      cell: "cell", 
      id: "id", 
      subgrid: { 
       root: "rows", 
       repeatitems: true, 
       cell: "cell", 
       id: "id" 
      } 
     }, 
     subGrid: true, 
     subGridUrl: '@Url.Action("GetGamlaSkeppsdagboksrader")', 
     subGridModel: [ 
      { 
       name: [ 
       'Datum', 
       'Tid', 
       'Tkn', 
       'Lat', 
       'Tkn', 
       'Long', 
       'Kurs', 
       'Fart', 
       'Anteckning', 
       'Sign', 
       'OK', 
       'Skapad'], 
       width: [ 
        70, 
        35, 
        20, 
        50, 
        20, 
        50, 
        40, 
        40, 
        150, 
        50, 
        50, 
        100 
       ] 
      } 
     ], 
     onSelectRow: function (id) { 
      getSkeppsdagboksanteckning(id); 
     } 
    }); 

回答

0

我想你可以使用你的子網格作爲網格,然後你可以使用與jqGrid相關的事件。看看這link作進一步參考。

+0

是的,這可能工作。儘管我做了很多返工。我希望有一個更簡單的方法! – kaze 2012-08-14 11:18:39