[eluser]teddy[/eluser]
everything is ok when I used Jqgrid with php, but when I apply to script below with views in codeigniter I have meet some troubles
1. Formate datetime is just show date and time is show 00:00:00
2. Jqgird not show filter toolbar
I don't know what happen with my code, or I miss something. Thank you for reading my topic
Code: [removed]
$(document).ready(function (){
jQuery("#list").jqGrid({
url:'<?=$base_url.'index.php/admin/users/list_users'?>',
mtype : "post",
datatype: "json",
colNames:['id','Họ tên','username','Email','Ngày đăng ký'],
colModel:[
{name:'id', index:'id', width:55,hidden:true},
{name:'hoten',index:'hoten', width:100, align:"left",sortable:true},
{name:'username',index:'username', width:150, align:"left",search:true,sortable:true},
{name:'Email',index:'phone', width:100, align:"right",search:true,sortable:true},
{name:'date_added', index:'date_added'
,formatter:'date', formatoptions: {newformat:'d-m-Y: H:i:s'}
, align:'center',search:true,sortable:true}
],
rowNum:10,
width: 750,
height: 300,
rowList:[10,20,30],
pager: '#pager',
sortname: 'id',
viewrecords: true,
rownumbers: true,
//loadonce:true,
gridview: true,
caption:"Danh sách Users"
}).navGrid('#pager',{edit:true,add:true,del:true,refesh:true});
});
jQuery('#list').jqGrid('filterToolbar', { searchOnEnter: true, enableClear: false });
[removed]
[eluser]teddy[/eluser]
I found some errors in my code and everything is ok, but I am seeking some tutorials about master detail with jqgrid I did it but subgrid is not show is nothing just show text loading...
My js script
Code: $(function()
{
jQuery("#list").jqGrid({
url:'<?=$base_url.'index.php/admin/users/list_users'?>',
editurl:'<?=$base_url.'index.php/admin/users/crud'?>',
datatype: "json",
mtype : "post",
colNames:['id','Họ tên','username','Email','Ngày đăng ký','Active'],
colModel:[
{name:'id', index:'id', width:55,hidden:true},
{name:'hoten',index:'hoten', width:100, align:"left",sortable:true,editable:true},
{name:'username',index:'username', width:150, align:"left",search:true,sortable:true,editable:true},
{name:'Email',index:'email', width:100, align:"right",search:true,sortable:true},
{name:'date_added', index:'date_added'
,formatter:'date', formatoptions: {newformat:'d-m-Y H:i:s'}
, align:'center',search:true,sortable:true},
{name:'Active',index:'active', width:100, align:"right",search:true,sortable:true
,edittype:'checkbox',editoptions: { value:"True:False" }
,formatter: "checkbox", formatoptions: {disabled : false},align:'center'},
],
rowNum:10,
width: 750,
height: 300,
rowList:[10,20,30],
pager: '#pager',
sortname: 'id',
viewrecords: true,
rownumbers: true,
loadonce:true,
gridview: true,
multiselect:true,
caption:"Danh sách Users",
subGrid:true,
subGridUrl:'<?=$base_url.'index.php/admin/users/getDetails'?>',
subGridModel: [{ name : ['tieude','date_added'], width : [200,55], params:['user_id']} ]
});
$("#list").jqGrid('navGrid', '#pager', { edit: false,add: false, del: true, });
jQuery("#list").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false});
jQuery("#list").jqGrid('inlineNav',"#pager");
});
and here is my subgrid controller
Code: function getDetails()
{
$id=$_POST['id'];
$sql="select * from tbl_posts where user_id='$id'";
$rs=$this->db->query($sql)->result_array();
$i=0;
foreach($rs as $row) {
$responce->rows[$i]['id']=$row->id;
$responce->rows[$i]['cell']=array($row->id,$row->tieude,$row->date_added);
$i++;
}
echo json_encode($responce);
}
[eluser]robertorubioes[/eluser]
Hi,
always double quotes for JSON
Try it!
[eluser]teddy[/eluser]
@robertorubioes: please explain more, tk
|