我还是 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