Search code examples
phpslickgrid

How to add check box in slickgrid?


i am still new in slickgrid so i 'm trying to follow the simple example of using a DataView with the SlickGrid jQuery plugin. However I can't work out how the data is added to the DataView.

here the code:

$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);

i am doesn't know how to add id for check box in code above. here the code https://rapidshare.com/files/3188523206/slickgrid.rar


Solution

  • Your code sample above and the question title do not correlate at all. Could you please either rephrase the question or provide the relevant code? You mention DataView - but your code above doesn't use DataView at all.