jQuery UI Widgets Forums Grid cellsrenderer without datafield

This topic contains 2 replies, has 2 voices, and was last updated by  Dimitar 8 years, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • cellsrenderer without datafield #85064

    mario santanche
    Participant

    Hi,
    I would to merge two fields in one column.
    I use this code:

    var dataAdapter1 = new $.jqx.dataAdapter(source);
    
    var cellsrenderer1 = function (row, columnfield, value, defaulthtml, columnproperties, rowdata) {
          		return "<ul ><li>" + rowdata.raggruppamento + "</li><ul><li>" + rowdata.membro + "</li></ul><li>"+ rowdata.partecipante + "                                                                                                                                                         </li></ul>";
    			}
    			
     var cellsrenderer2 = function (row, columnfield, value, defaulthtml, columnproperties, rowdata) {
       
    		return "<ul ><li>" + rowdata.aggiudicatarioRaggruppamento + "</li><ul><li>" + rowdata.membro + "</li></ul><li>"+ rowdata.aggiudicatario + "</li></ul>";
            
                         }
    			
    				
    				 $("#jqxgrid").jqxGrid(
                             {
                                    width: 1240,
    				autorowheight:true,
    				autoheight: true,
    				localization: getLocalization(),
    				pageable: true,
                                    source: dataAdapter1,
    				filterable: true,
    				showfilterrow: true,
    				theme:theme,
    				pagesize:20,
    				pagesizeoptions: ['10', '20', '50','100'],
    				enablehover: false,
    				enablebrowserselection: true,
    	
                               columns: [
    								
    				{ text: 'CIG', datafield: 'cig', width:100  },
    				{ text: 'Oggetto', datafield: 'oggetto', width:180  },
    				{ text: 'Scelta Contraente', datafield: 'sceltaContraente', width:140 },
    				{ text: 'Partecipanti',  cellsrenderer: cellsrenderer1, width:200},
    				{ text: 'Aggiudicatari',  cellsrenderer: cellsrenderer2, width:200},
    				{ text: 'Aggiudicazione', datafield: 'importoAggiudicazione', cellsformat:'c2', width:125  },
    				{ text: 'Somme liquidate', datafield: 'importoSommeLiquidate', cellsformat:'c2', width:125  },
    				{ text: 'Data Inizio', datafield: 'dataInizio', width:85, cellsformat: 'dd/MM/yyyy'  },
    				{ text: 'Data Fine', datafield: 'dataUltimazione' , width:85, cellsformat: 'dd/MM/yyyy' },
    	
                                        ],
    				  
                                     });
    
    $('#jqxButtonStampaRiv').bind('click', function (event) {
                    var data =$("#jqxgrid").jqxGrid('exportdata', 'csv');
    
    });

    This works fine! It’s very strange for me to have a column without datafield (see “Partecipanti” and “Aggiudicatari”), but I reached my goal: in my cell I’ve now a list (ul) that merges two datafields.

    Unfortunately I need also to export my data in csv format, but when I use the grid export function (var data =$("#jqxgrid").jqxGrid('exportdata', 'csv');) I lost “Partecipanti” and “Aggiudicatari”.
    There is a better solution for merging two datafield in one grid column?
    Thank You for any help,
    Mario

    cellsrenderer without datafield #85068

    mario santanche
    Participant

    Oh my God! “Is there …?” of course!

    cellsrenderer without datafield #85089

    Dimitar
    Participant

    Hello mario santanche,

    The proper solution for merging two datafields in one column is by using cellsrenderer. Please note, however, that content rendered with cellsrenderer cannot be exported. As an alternative, you can merge only the data in the data adapter‘s beforeLoadComplete callback function, but you will still not be able to export it as <ul>.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.