EasyUI Forum
April 29, 2024, 06:22:57 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: [SOLVED] How to get value on row when use name field contain dot (ex:e.name)  (Read 12438 times)
neos
Newbie
*
Posts: 31


View Profile
« on: March 04, 2015, 01:40:07 AM »

Dear All,

I have Datagrid with field like below :
Code:
<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 :
Code:
$('#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".
« Last Edit: March 11, 2015, 07:01:21 PM by neos » Logged
neos
Newbie
*
Posts: 31


View Profile
« Reply #1 on: March 04, 2015, 09:12:20 PM »

Anyone have idea ??  Huh
Logged
neos
Newbie
*
Posts: 31


View Profile
« Reply #2 on: March 05, 2015, 10:38:46 AM »

still confused  Huh Huh
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: March 05, 2015, 07:09:55 PM »

The nested field name is not supported, please use the 'formatter' function instead.
Code:
<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>
Logged
neos
Newbie
*
Posts: 31


View Profile
« Reply #4 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 ?  Huh
Logged
neos
Newbie
*
Posts: 31


View Profile
« Reply #5 on: March 05, 2015, 08:40:41 PM »

I was change such as you clue. but still error ? how to access this field ?
Code:
<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>

Code:
$('#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 ?  Huh
Logged
neos
Newbie
*
Posts: 31


View Profile
« Reply #6 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
Logged
neos
Newbie
*
Posts: 31


View Profile
« Reply #7 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.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!