EasyUI Forum

General Category => Bug Report => Topic started by: mazvv on July 05, 2015, 09:24:24 AM



Title: Datagrid formatter problem 1.4.3
Post by: mazvv on July 05, 2015, 09:24:24 AM
Hello.
After update from 1.4.2 to 1.4.3 formatter and styler function for datagrid does not work.
Code:
        <thead>
            <th data-options="field:'status',sortable:false,width:60,formatter:function(value, row, index){return status_formatter(value);}">${_(u"status")}</th>
            <th data-options="field:'modifydt',sortable:true,width:120,styler:function(){return datagrid_resource_cell_styler();}"><strong>${_(u"updated")}</strong></th>
            <th data-options="field:'modifier',width:100,styler:function(){return datagrid_resource_cell_styler();}"><strong>${_(u"modifier")}</strong></th>
        </thead>
I use detailview


Title: Re: Datagrid formatter problem 1.4.3
Post by: jarry on July 05, 2015, 02:58:44 PM
Please show an example to demonstrate your issue.


Title: Re: Datagrid formatter problem 1.4.3
Post by: mazvv on July 07, 2015, 12:49:56 PM
My full code
Code:
    <table class="easyui-datagrid"
        id="${_id}"
        data-options="
            url:'${request.resource_url(_context, 'list')}',border:false,
            pagination:true,fit:true,pageSize:50,singleSelect:true,
            sortName:'deadline',sortOrder:'asc',
            pageList:[50,100,500],idField:'_id',checkOnSelect:false,
            selectOnCheck:false,toolbar:'#${_tb_id}',
            view: detailview,
            onExpandRow: function(index, row){
                var row_id = 'row-${_id}-' + row.id;
                $('#' + row_id).load(
                    '/tasks/details?id=' + row.id,
                    function(){
                        $('#${_id}').datagrid('fixDetailRowHeight', index);
                        $('#${_id}').datagrid('fixRowHeight', index);
                        $.parser.parse('#' + row_id);
                    }
                );
            },
            detailFormatter: function(index, row){
                var row_id = 'row-${_id}-' + row.id;
                return '<div id=' + row_id + '></div>';
            },          
            onBeforeLoad: function(param){
                param.performer_id = ${h.common.get_auth_employee(request).id};
                $.each($('#${_tb_id} .searchbar').find('input'), function(i, el){
                    if(!is_undefined($(el).attr('name')))
                        param[$(el).attr('name')] = $(el).val();
                });
            }
        " width="100%">
        <thead>
            % if _context.has_permision('delete'):
            <th data-options="field:'_id',checkbox:true">${_(u"id")}</th>
            % endif
            <th data-options="field:'title',sortable:true,width:180">${_(u"title")}</th>
            <th data-options="field:'status',sortable:false,width:60,formatter:function(value, row){return status_formatter(value);}">${_(u"status")}</th>
            <th data-options="field:'deadline',sortable:true,width:110,styler:function(){return datagrid_resource_cell_styler();}">${_(u'deadline')}</th>
        </thead>
    </table>
status_formatter function
Code:
function status_formatter(status){
if(status){
var span = $('<span/>').html(status.title);
span.addClass('status-label ' + status.key);
return $('<div/>').append(span).html();
}
}
functions status_formatter and datagrid_resource_cell_styler does not calls


Title: Re: Datagrid formatter problem 1.4.3
Post by: jarry on July 07, 2015, 05:35:14 PM
Please refer to this example http://jsfiddle.net/8foyt6q9/. It works fine.