Title: [SOLVED] How to get value on row when use name field contain dot (ex:e.name)
Post by: neos on March 04, 2015, 01:40:07 AM
Dear All, I have Datagrid with field like below : <table id="grid-transaksi_izin" data-options="pageSize:50, multiSort:true, remoteSort:false, rownumbers:true, singleSelect:true, fit:true, fitColumns:false, toolbar:toolbar_transaksi_izin"> <thead> <tr> <th data-options="field:'ck',checkbox:true" ></th> <th data-options="field:'fizin_id'" width="50" halign="center" align="center" sortable="true">ID</th> <th data-options="field:'fizin_tanggal'" width="100" halign="center" align="center" sortable="true">Tanggal</th> <th data-options="field:'d.karyawan_nama'" width="150" halign="center" align="center" sortable="true">Nama Karyawan</th> <th data-options="field:'c.departemen_nama'" width="100" halign="center" align="center" sortable="true">Departemen</th> <th data-options="field:'b.departemen_nama'" width="100" halign="center" align="center" sortable="true">Bagian</th> <th data-options="field:'fizin_jenis'" width="100" halign="center" align="center" sortable="true">Jenis Izin</th> <th data-options="field:'fizin_dari'" width="150" halign="center" align="center" sortable="true">Dari</th> <th data-options="field:'fizin_sampai'" width="150" halign="center" align="center" sortable="true">Sampai</th> <th data-options="field:'fizin_keperluan'" width="150" halign="center" align="center" sortable="true">Keperluan</th> <th data-options="field:'fizin_timestamp'" width="150" halign="center" align="center" sortable="true">Tanggal Pembuatan</th> <th data-options="field:'e.name'" width="70" halign="center" align="center" sortable="true">Disetujui</th> <th data-options="field:'f.name'" width="70" halign="center" align="center" sortable="true">Diketahui</th> </tr> </thead> </table>
i want to get value from field e.name with code like below : $('#grid-transaksi_izin').datagrid({view:scrollview,remoteFilter:true, url:'<?php echo site_url('transaksi/izin/index'); ?>?grid=true'}) .datagrid({ onLoadSuccess: function(data){ $('#izin_edit').linkbutton('disable'); $('#izin_delete').linkbutton('disable'); }, onClickRow: function(index,row){ if(row.e.name === null){ $('#izin_edit').linkbutton('enable'); $('#izin_delete').linkbutton('enable'); } else{ $('#izin_edit').linkbutton('disable'); $('#izin_delete').linkbutton('disable'); } } }).datagrid('enableFilter');
but allways get error "Cannot read property 'name' of undefined".
Title: Re: How to get value on row when use name field ex:e.name
Post by: neos on March 04, 2015, 09:12:20 PM
Anyone have idea ?? ???
Title: Re: How to get value on row when use name field contain dot (ex:e.name)
Post by: neos on March 05, 2015, 10:38:46 AM
still confused ??? ???
Title: Re: How to get value on row when use name field contain dot (ex:e.name)
Post by: stworthy on March 05, 2015, 07:09:55 PM
The nested field name is not supported, please use the 'formatter' function instead. <th data-options="field:'e.name'" width="70" halign="center" align="center" sortable="true" data-options="formatter:function(v,r){return r.e.name}">Disetujui</th> <th data-options="field:'f.name'" width="70" halign="center" align="center" sortable="true" data-options="formatter:function(v,r){return r.f.name}">Diketahui</th>
Title: Re: How to get value on row when use name field contain dot (ex:e.name)
Post by: neos on March 05, 2015, 07:55:06 PM
Thx stworthy for your reply,
in formatter datagrid have 3 parameter (formatter: function(value,row,index)). in your clue just 2 parameter. what the mean function(v,r) ? can you explain more detail ? ???
Title: Re: How to get value on row when use name field contain dot (ex:e.name)
Post by: neos on March 05, 2015, 08:40:41 PM
I was change such as you clue. but still error ? how to access this field ? <table id="grid-transaksi_izin" data-options="pageSize:50, multiSort:true, remoteSort:false, rownumbers:true, singleSelect:true, fit:true, fitColumns:false"> <thead> <tr> <th data-options="field:'e.name'" width="70" halign="center" align="center" sortable="true" data-options="formatter:function(v,r){return r.e.name}">Disetujui</th> <th data-options="field:'f.name'" width="70" halign="center" align="center" sortable="true" data-options="formatter:function(v,r){return r.f.name}">Diketahui</th> </tr> </thead> </table>
$('#grid-transaksi_izin').datagrid({view:scrollview,remoteFilter:true, url:'<?php echo site_url('transaksi/izin/index'); ?>?grid=true'}) .datagrid({ onClickRow: function(index,row){ alert(row.e.name); } }).datagrid('enableFilter');
is there something wrong ? ???
Title: Re: How to get value on row when use name field contain dot (ex:e.name)
Post by: neos on March 05, 2015, 08:50:12 PM
this is a jason data {"total":1,"rows":[{"fizin_id":"3","fizin_tanggal":"2015-02-20","fizin_nik":"090900","fizin_bagian":"14","fizin_jenis":"TIDAK HADIR","fizin_dari":"2015-02-23 14:15:03","fizin_sampai":"2015-02-23 14:15:45","fizin_keperluan":"Kep. Keluarga","fizin_timestamp":"2015-02-20 14:16:08","fizin_disetujui":"1","fizin_diketahui":"2","c.departemen_nama":"QA","b.departemen_nama":"COI","d.karyawan_nama":"Romi Rafael","e.name":"Agus Setiawan","f.name":"Dedi Sukardi"}]}
the field is not nested field but the field name from sql query is e.name and f.name
Title: Re: How to get value on row when use name field contain dot (ex:e.name)
Post by: neos on March 05, 2015, 09:09:14 PM
I was solve my problem.
i just use row['e.name'] to get the value.
thx stworthy.
|