EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Opan Mustopah on January 17, 2015, 01:18:05 AM



Title: hide columns when editing row.[solved]
Post by: Opan Mustopah on January 17, 2015, 01:18:05 AM
hello again,

just to the point.
i want to some column/editor when editing a row with some condition.
here is how defined it:
Code:

onBeginEdit:function(index,row){
        // start list editor yang memiliki rules
        var transport_mode = $(this).datagrid('getEditor',{index:index,field:'transport_mode_id'});
        var port_ori = $(this).datagrid('getEditor',{index:index,field:'port_id_ori'});
        var port_dest = $(this).datagrid('getEditor',{index:index,field:'port_id_dest'});
        var zone_ori = $(this).datagrid('getEditor',{index:index,field:'zone_id_ori'});
        var zone_dest = $(this).datagrid('getEditor',{index:index,field:'zone_id_dest'});
        var nw = $(this).datagrid('getEditor',{index:index,field:'nw'});
        var gw = $(this).datagrid('getEditor',{index:index,field:'gw'});
        // stop list editor yang memiliki rules

        // start dapatkan options column
        var port_ori_opt = $(this).datagrid('getColumnOption','port_id_ori'); // in this i test to hide port_id_ori column when begin editing.
        port_ori_opt.hidden = true;
        console.log(port_ori_opt);

        // stop dapatkan options column
        $(port_ori.target).combogrid({
          onChange:function(newValue,oldValue){
            var port_dest_val = $(port_dest.target).combogrid('getValue');
            var port_ori_val = $(this).combogrid('getValue');
            if (port_ori_val != "" && port_dest_val != ""){
              if (newValue == port_dest_value){
                $.messager.alert('Info','Port Ori and Port Dest cannot be same.','info');
                $(this).combogrid('setValue','');
                $(this).focus();
              }
            }
          }
        });

        $(port_dest.target).combogrid({
          onChange:function(newValue,oldValue){
            var port_dest_val = $(this).combogrid('getValue');
            var port_ori_val = $(port_ori.target).combogrid('getValue');
            if (port_dest_val != "" && port_ori_val != ""){
              if (newValue == port_ori_val){
                $.messager.alert('Info','Port Ori and Port Dest cannot be same.','info');
                $(this).combogrid('setValue','');
                $(this).focus();
              }
            }
          }
        });

        $(nw.target).numberbox({
          onChange:function(newValue,oldValue){
            var nw_val = $(this).numberbox('getValue');
            var gw_val = $(this).numberbox('getValue');
            if (nw_val != "" && gw_val != ""){
              if (!isNaN(gw_val) && !isNaN(nw_val)){
                if (parseFloat(nw_val) > parseFloat(gw_val)){
                  $.message.alert('Info',"NW must be lower than GW",'info');
                  $(this).focus();
                  $(this).numberbox('setValue','0');
                }
              }
            }
          }
        });
}


but it's not working, port_id_ori not hidden at all.
whats wrong with my code?

many thanks for the answer


Title: Re: hide columns when editing row.
Post by: stworthy on January 17, 2015, 08:07:16 AM
To hide a column, please call 'hideColumn' method instead.
Code:
var field = ...;
$('#dg').datagrid('hideColumn', field);


Title: Re: hide columns when editing row.
Post by: Opan Mustopah on January 17, 2015, 08:33:29 AM
oh god, i really not see that method, thank you very much stworthy.