我仍然是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
答案 0 :(得分:0)
上面的代码示例和问题标题完全没有关联。您能否重新提出问题或提供相关代码?你提到DataView - 但你上面的代码根本不使用DataView。