0

我还是 slickgrid 的新手,所以我正在尝试使用带有 SlickGrid jQuery 插件的 DataView 的简单示例。但是我无法弄清楚数据是如何添加到 DataView 中的。

这里的代码:

$data = '';
$i = 0;

$query = "SELECT * FROM tahun";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
    $data .= '
        data['.$i.'] = {

            spt: "'.$row['ID'].'",
            nama: "'.$row['nama'].'",
            alamat: "'.$row['alamat'].'",
            bayar: "'.$row['tanggal_bayar'].'",
            hutang: "'.$row['tanggal_hutang'].'",
            perkiraan: "'.$row['perkiraan'].'",
        };
    ';
    $i++;
}



 var grid;
  var columns = [

        {id:"spt", name:"ID", field:"spt",sortable: true},
        {id:"nama", name:"Nama", field:"nama",sortable: true},
        {id:"alamat", name:"Alamat", field:"alamat",sortable: true},
        {id:"bayar", name:"Bayar", field:"bayar",sortable: true},
        {id:"hutang", name:"Hutang", field:"hutang",sortable: true},
        {id:"perkiraan", name:"Perkiran", field:"perkiraan",sortable: true}

    ];

    var options = {
        enableCellNavigation: true,
        enableColumnReorder: false,
        multiColumnSort: true,
        editable: true,
        asyncEditorLoading: false,
        autoEdit: false
    };
    var columns = [];

  $(function() {
       var checkboxSelector = new Slick.CheckboxSelectColumn({
      cssClass: "slick-cell-checkboxsel"
    });
    columns.push(checkboxSelector.getColumnDefinition());

    columns.push({
        var data = [];
        <?=$data?> //This is where we echo the PHP variable $data which contains our JavaScript array as a string.
        });
        grid = new Slick.Grid($("#myGrid"), data, columns, options);

    grid.setSelectionModel(new Slick.RowSelectionModel({selectActiveRow: false}));
    grid.registerPlugin(checkboxSelector);

我不知道如何在上面的代码中为复选框添加 id。这里的代码 https://rapidshare.com/files/3188523206/slickgrid.rar

4

1 回答 1

0

您上面的代码示例和问题标题根本不相关。您能否改写问题或提供相关代码?您提到 DataView - 但您上面的代码根本不使用 DataView。

于 2012-04-27T04:15:45.110 回答