jQWidgets Forums
jQuery UI Widgets › Forums › Grid › aggregates doesn’t show!!
Tagged: datagrid aggregates, grid aggregates
This topic contains 8 replies, has 2 voices, and was last updated by jose Ivan 12 years, 6 months ago.
-
Author
-
Hi , i got a weard situation.
aggregates doesn’t show , i include the aggregates.js and i add the part of code in my column and the property. i got a method $.ajax to get the data so i think maybe it is the problem. is there a way to do aggregates maybe on ready or something because does show nothing.
function GetDatabyAjax(URl, data, sucess, error) { $ = jQuery.noConflict(); $.ajax({ type: 'POST', url: URl, data: data , contentType: 'application/json; charset=utf-8', dataType: 'json', success: sucess, error: sucessokey }); } function sucessokey(result) { var source = { datatype: "json", datafields: [ { name: 'ready' } ] }; var respuesta = $.parseJSON(result.d); source.localdata = respuesta.result; var cantidad = respuesta._columnInfos.length; for (var i = 0; i < cantidad; i++) { var fila = respuesta._columnInfos[i]; gridColumns.push({ text: fila.hearder, dataField: fila.datafield, cellsalign: 'left', width: 120 }); } cantidad = respuesta._datas.length; for (var i = 0; i < cantidad; i++) { source.datafields.push({ name: respuesta._datas[i].datafields }); } var dataAdapter = new $.jqx.dataAdapter(source); $('#grid').jqxGrid({ source: source }); } $('#grid').jqxGrid({ width: '100%', editable: true, altrows: true, enablehover: true, enabletooltips: true, enableanimations: true, keyboardnavigation: true, autoheight: true, pageable: false, columnsresize: true, theme:'classic', editmode: 'selectedcell',selectionmode: 'singlecell', showstatusbar: true, statusbarheight: 50, showaggregates: true, ready: function () { $('#grid').jqxGrid('selectcell', 0, 'aco'); $('#grid').jqxGrid('wrapper').focus(); }, columns: [ { text: '', columntype: 'checkbox', width: 40, datafield: 'ready' } { text: 'aco', dataField: 'aco', width: 100 }, { text: 'cr',datafield: 'cr', width: 100 ,cellsalign: 'right', cellsformat: 'c2',symbolPosition: 'left',aggregates:['sum'] }, { text: 'de',datafield: 'de', width: 100 ,cellsalign: 'right', cellsformat: 'c2',symbolPosition: 'left',aggregates:['sum'] }, ] }); //fin del Grid this have to show it when it load! no when i click a button or something like that.
i got the 2.4.1 v
Hi jose Ivan,
The Grid should be bound to a dataAdapter built from a source object, not to a source object. Example: http://jsfiddle.net/jqwidgets/PHhpR/
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi, thanks that’s works but the sum show me $ 0 , i can figure out that’s because when it built doesn’t have datasource , if you see i set the datasource in callback. How can i update this values?
thanks for replay.
Hi jose Ivan,
You are doing something which is not correct.
var dataAdapter = new $.jqx.dataAdapter(source); $('#grid').jqxGrid({ source: source });
The code should be:
var dataAdapter = new $.jqx.dataAdapter(source); $('#grid').jqxGrid({ source: dataAdapter });
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comAnd
var dataAdapter = new $.jqx.dataAdapter(source);
$(‘#SuperGrid’).jqxGrid({ source: dataAdapter });Hi, thanks for replay.
well thanks but i did it and show me numbers like
$2.9460012001000004e+21
and
$100,002,588,000,310,000.00what it is am i doing wrong ?
that my code :
$(document).ready(function () {
$('#SuperGrid').jqxGrid({
width: '100%',
editable: true, altrows: true, enablehover: true, enabletooltips: true,
enableanimations: true, keyboardnavigation: true, autoheight: true, pageable: false,
columnsresize: true, theme:'classic',
editmode: 'selectedcell',selectionmode: 'singlecell',
showstatusbar: true, statusbarheight: 50, showaggregates: true,
ready: function () {
$('#SuperGrid').jqxGrid('selectcell', 0, 'acc');
$('#SuperGrid').jqxGrid('wrapper').focus();
},
columns:
[
{ text: '', columntype: 'checkbox', width: 40, datafield: 'ready'},
{ text: 'acc', dataField: 'acc', width: 100 },
{ text: 'credit',datafield: 'credit', width: 100 ,cellsalign: 'right', cellsformat: 'c2',
symbolPosition: 'left',
aggregates:[{'total_credit': function(Value, currentValue, column, record) { return currentValue+ Value } }],
aggregatesrenderer :function(aggregates) {
var renderstring = aggregates['total_credit'];
return '' + renderstring + '';
}
},
{ text: 'debit',datafield: 'debit', width: 100 ,cellsalign: 'right', cellsformat: 'c2',
symbolPosition: 'left',
aggregates: [{'total_debit': function(Value, currentValue, column, record) { return currentValue+ Value } }],
aggregatesrenderer :function(aggregates) {
var renderstring = aggregates['total_debit'];
return '' + renderstring + '';
}
},
{ text: 'notes', dataField: 'notes', width: 100 },
{ text: 'proyecto', dataField: 'proyecto', width: 100 }
]
}); //fin del Grid
}); //document ready
As far as I see, you create custom Aggregates. Your code is:
aggregates:[{'total_credit': function(Value, currentValue, column, record) { return currentValue+ Value } }
This may result in concatenation of strings, not numbers. However, you should always use only numeric data for aggregates. Therefore, providing a small sample in which this can be observed locally will be appreciated. Feel free to send your sample to support@jqwidgets.com. I don’t see how we can help you without a sample, because the provided information is not enough for testing your scenario locally.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi , thanks for replay again .
Well it seems the problem is string as you told it.
I fixed this with “parsefloat” but it weird because i try it before with static data and it works. well thanks anyway.
-
AuthorPosts
You must be logged in to reply to this topic.