jQuery UI Widgets › Forums › Grid › Best way to load in the grid
Tagged: performance
This topic contains 1 reply, has 2 voices, and was last updated by Ivo Zhulev 8 years, 8 months ago.
-
Author
-
Hi, I have one doubt, for load the elements in the grid I use array, but I use two way for load the elements, which way have best performance??
the first is the next one:
var source = { localdata: getEventos(), datatype: 'array', datafields: [ { name: 'ID', type: 'number' }, { name: 'EntidadId', type: 'number' }, { name: 'Entidad', type: 'string' }, { name: 'CveEvento', type: 'string' }, { name: 'Estado', type: 'string' }, { name: 'Nombre', type: 'string' }, ] }; var dataAdapter = new $.jqx.dataAdapter(source); var columns = [ { text: 'ID', datafield: 'ID', hidden: true }, { text: 'EntidadId', datafield: 'EntidadId', hidden: true }, { text: 'Entidad', datafield: 'Entidad', align: 'Center', width: 160 }, { text: 'Clave de Evento', datafield: 'CveEvento', align: 'Center', width: 260 }, { text: 'Nombre', datafield: 'Nombre', align: 'Center', width: 420 }, { text: 'Estado', datafield: 'Estado', align: 'Center', cellsalign: 'center', width: 160 } ]; $('#jqxgridEventos').jqxGrid( { height: 300, width: 1000, source: dataAdapter, showfilterrow: true, filterable: true, sortable: true, columnsresize: true, autoshowfiltericon: true, columns: columns } );
the function getEventos in the source return me an array
the second one is in a inside in the function set the array directly to the grid:
function on_Success() { var data = []; var collection = items.getEnumerator(); while (items = collection.moveNext()) { var item = collection.get_current(); var id = item.get_id(); var noAccion = item.get_item('NoAccion'); var cveAccion = item.get_item('Title'); var tipo = item.get_item('Tipo'); var tramo = item.get_item('TramoCarretero'); var autorizado = item.get_item('AutorizadoModif'); row = {}; row['ID'] = id; row['No'] = noAccion; row['Tipo'] = tipo; row['Tramo'] = tramo; row['Autorizado'] = autorizado; data.push(row); } $("#jqxgridAcciones").jqxGrid('hideloadelement'); $("#jqxgridAcciones").jqxGrid('addrow', null, data); }
thanks.
Hi Francisco Ortega,
The first one definitely. There is a lot less interpreting the browser must do to understand it. Also the code is better to read and maintain.
Best Regards,
IvojQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.