0
我仍然是新的slickgrid,所以我試圖遵循使用DataView與SlickGrid jQuery插件的簡單示例。但是我無法弄清楚數據是如何添加到DataView的。如何在slickgrid中添加複選框?
這裏的代碼:
$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