EasyUI Forum
March 29, 2024, 03:29:56 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Problem with datagrid columns width  (Read 5241 times)
danny36
Newbie
*
Posts: 9


View Profile Email
« on: July 18, 2017, 02:50:44 AM »

Hello,

I have a datagrid with json remote data but the columns headers don't fit the width of the rows cell, see picture.

How can I fit columsn P.1, P.2, ecc to the same fixed width?

this is my datagrid code:


function getClassificaTrofeo(classifica, title){
                var tabella = '#tabella_classifica_trofeo_'+classifica;
                var url = 'classifica_trofeo.php?class='+classifica;

                console.log(url);
                $(tabella).datagrid({
                    title: title,
                    url: url,
                    striped: true,
                    fitColumns: true,
                    fit: true,
                    pagination: true,
                    method: 'get',
                    rownumbers: true,
                    loadMsg: 'Attendere caricamento dati!',
                    pageList: [100,150,200,300,500,1000],
                    toolbar:  [{
                        text:'Stampa',
                        iconCls:'icon-pdf',
                        handler:function(){
                            $.messager.confirm('Conferma!', 'Vuoi stampare questa classifica?', function(r){
                                if (r)
                                {
                                    $.post(
                                        'dummypage.html',
                                        function(data)
                                        {
                                            window.open(encodeURI('classifica_pdf.php?class='+classifica+'&id_gara=<?php echo $id_gara; ?>'));
                                        });
                                }
                            });
                        }
                    },
                        {
                            text:'Esporta',
                            iconCls:'icon-export',
                            handler:function(){esportaClassifica(classifica, title)}
                        },
                    ],
                    columns:[[
                        {field:'nome',title:'Nome', width: 100, resizable: false},
                        {field:'societa',title:'Societa', width: 100, resizable: false},
                        {field:'categoria',title:'Cat.',resizable: false},
                        {field:'punteggio',title:'Punti',resizable: false},
                        {field:'punti_singole_gare[0].punti_assoluto',title:'P.1', align:'center', resizable: false, formatter:function(value,row){
                            return row.punti_singole_gare[0].punti_assoluto;
                        }},
                        {field:'punti_singole_gare[1].punti_assoluto',title:'P.2',align:'center', resizable: false, formatter:function(value,row){
                            return row.punti_singole_gare[1].punti_assoluto;
                        }},
                        {field:'punti_singole_gare[2].punti_assoluto',title:'P.3',align:'center', resizable: false, formatter:function(value,row){
                            return row.punti_singole_gare[2].punti_assoluto;
                        }},
                        {field:'punti_singole_gare[3].punti_assoluto',title:'P.4',align:'center', resizable: false, formatter:function(value,row){
                            return row.punti_singole_gare[3].punti_assoluto;
                        }},
                        {field:'punti_singole_gare[4].punti_assoluto',title:'P.5',align:'center', resizable: false, formatter:function(value,row){
                            return row.punti_singole_gare[4].punti_assoluto;
                        }},
                        {field:'punti_singole_gare[5].punti_assoluto',title:'P.6',align:'center', resizable: false, formatter:function(value,row){
                            return row.punti_singole_gare[5].punti_assoluto;
                        }},
                        {field:'punti_singole_gare[6].punti_assoluto',title:'P.7',align:'center', resizable: false, formatter:function(value,row){
                            return row.punti_singole_gare[6].punti_assoluto;
                        }},
                        {field:'punti_singole_gare[7].punti_assoluto',title:'P.8',align:'center', resizable: false, formatter:function(value,row){
                            return row.punti_singole_gare[7].punti_assoluto;
                        }},
                        {field:'punti_singole_gare[8].punti_assoluto',title:'P.9',align:'center', resizable: false, formatter:function(value,row){
                            return row.punti_singole_gare[8].punti_assoluto;
                        }},
                        {field:'punti_singole_gare[9].punti_assoluto',title:'P.10',align:'center', resizable: false, formatter:function(value,row){
                            return row.punti_singole_gare[9].punti_assoluto;
                        }},
                        {field:'punti_singole_gare[10].punti_assoluto',title:'P.11',align:'center', resizable: false, formatter:function(value,row){
                            return row.punti_singole_gare[10].punti_assoluto;
                        }},
                        {field:'punti_singole_gare[11].punti_assoluto',title:'P.12',align:'center', resizable: false, formatter:function(value,row){
                            return row.punti_singole_gare[11].punti_assoluto;
                        }}

                    ]]
                });
                $(tabella).datagrid('reload');
            }
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #1 on: July 18, 2017, 04:54:58 AM »

The field name contains illegal characters '[' and ']' such as 'punti_singole_gare[0].punti_assoluto'. Please replace it with 'punti_singole_gare_0_punti_assoluto'.
Logged
danny36
Newbie
*
Posts: 9


View Profile Email
« Reply #2 on: July 19, 2017, 12:13:19 AM »

thank you very much jarry.

but I don't understand the concept of the "field" Properties of column. The documentation say "The column field name." But if this name reflect the json data how works with "punti_singole_gare_0_punti_assoluto" that don't exist in my json data?
« Last Edit: July 19, 2017, 12:17:52 AM by danny36 » 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!