我的数据库中有一个简单的表tbl_task,具有以下属性:
- id int auto_increment
- 描述varchar
- 完全布尔值
现在我创建了一个网格视图。完整属性的值由一个复选框显示。应该有可能更改完整属性的值。如果您这样做,它应该将更改保存在数据库中。同时,gridview每隔3秒就会从数据库中获取最新的记录。
我试过修改gridview js文件,但它不起作用。
有人知道如何解决我的问题吗?
非常感谢。
这应该不难实现。
1) 为了每3秒更新一次网格,请使用javascript setInterval并调用网格的更新方法:
jQuery('#grid_id_here').yiiGridView('update');
2) 在完整列中,将其设置为"type" => "raw"
,然后将类似于"<input type='checkbox' onclick='mark_complete('.$data->id.')'>"
的内容设置为"value"
3) 定义一个javascript函数来完成任务
function mark_complete(id) {
// 1. make here a ajax call that updates the task's complete field
// 2. on the success of that ajax call place again the update command to update the grid
}