Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
How to get formatted average of jqgrid column by avg function.
06/12/2014
09:30
Avatar
ATUL SINGHAL
New Member
Members
Forum Posts: 1
Member Since:
09/10/2014
sp_UserOfflineSmall Offline

Hi All,

I have used jqgride and i am facing a problem when i want to find avg of a column for Ex-

sumFloat19 = grid.jqGrid('getCol', 'Loadfactor', true, 'avg');

it will give values like 73.4965517241 but i want 73.49, so help me solve this problem.

my 2nd problem is i want pagination but not want to pass dynamic value, not like that      rowList:[100,200,300],

 

 

  $("#lstReport").jqGrid('setGridParam', {url:'<%=request.getContextPath()%>/indiconsreport.do?method=condIndividual&fromdate='+fromdate+"&todate="+todate+"&region="+region+"&depot="+depot+"&condid="+condid,
                    datatype: "xml",
                    page: 1}).trigger("reloadGrid");
                jQuery("#lstReport").jqGrid({

                    url:'<%=request.getContextPath()%>/indiconsreport.do?method=condIndividual&fromdate='+fromdate+"&todate="+todate+"&region="+region+"&depot="+depot+"&condid="+condid,
                    datatype: "xml",
                    shrinkToFit : true,
                    pager: jQuery('#pgLstCustTx'),
                    colNames: ['Depot Code(A)','Duty_Date(B)','Conductor Name(C)','Collection Time(D)','RouteName (E)','WaybillNo (F)','ActualKM (G)','ScheduleKM (H)','NetIncome (I)','BaseFare (J)','Toll (K)','Bridge (L)','BasicFare (M=J+K-L)','BusTypeCode (N)','SeatCapacity (O)','VehicleNo (P)','IPKM (Q=M/G)','FarePerKM (R)','FCI (S=R*O)','LoadFactor (T=S/Q)'],
                    colModel: [
                        {name:'depot_cd',index:'depot_cd',width:100,searc:false,align:"left",editable:true,editoptions:{readonly: 'readonly'},key:true},
                        {name:'DUTY_DT',index:'DUTY_DT',width:100,searc:false,align:"left",editable:true,editoptions:{readonly: 'readonly'},key:true},
                        {name:'condName',index:'condName',width:100,searc:false,align:"left",editable:true,editoptions:{readonly: 'readonly'},key:true},
                        {name:'collection_tm',index:'collection_tm',width:100,search:false,editable:true,align:"right",editoptions:{readonly: 'readonly'},key:true},
                        {name:'route_nm',index:'route_nm',width:120,align:"left",search:false,editable:true,editrules:{required: 'true'}},
                        {name:'waybill_no',index:'waybill_no',width:80,align:"center",search:false,editable:true,editrules:{required: 'true'}},
                        {name:'actual_km',index:'actual_km',width:80,search:false,align:"center",editable:true,editoptions:{readonly: 'readonly'},key:true},
                        {name:'schedule_km',index:'schedule_km',width:50,search:false,editable:true,align:"center",editoptions:{readonly: 'readonly'},key:true},
                        {name:'netincome',index:'netincome',width:70,align:"right",search:false,editable:true,editrules:{required: 'true'}},
                        {name:'base_fare',index:'base_fare',width:90,align:"right",search:false,editable:true,editrules:{required: 'true'}},
                        {name:'toll_amount',index:'toll_amount',width:60,align:"right",search:false,editable:true,editrules:{required: 'true'}},
                        {name:'bridge',index:'bridge',width:60,align:"right",search:false,editable:true,editrules:{required: 'true'}},
                        {name:'basicfare',index:'basicfare',width:150,align:"right",search:false,editable:true,editrules:{required: 'true'}},
                        {name:'bus_type_cd',index:'bus_type_cd',width:50,align:"center",search:false,editable:true,editrules:{required: 'true'}},
                        {name:'seat_capacity',index:'seat_capacity',width:130,align:"center",search:false,editable:true,editrules:{required: 'true'}},
                        {name:'vehicle_no',index:'vehicle_no',width:80,align:"center",search:false,editable:true,editrules:{required: 'true'}},
                        {name:'ipkm',index:'ipkm',width:100,align:"center",search:false,editable:true,editrules:{required: 'true'}},
                         {name:'farePerKm',index:'farePerKm',width:120,align:"center",search:false,editable:true,editrules:{required: 'true'}},
                        {name:'fci',index:'fci',width:100,align:"center",search:false,editable:true,editrules:{required: 'true'}},
                        {name:'Loadfactor',index:'Loadfactor',width:130,sorttype:'int',jsonmap:"Loadfactor",align:"center",search:false,editable:true,editrules:{required: 'true'}}
                    ],

                    rowNum: 1000,
                    scroll: false,
                    mtype: "post",
                    rownumbers: true,
                    rowList:[100,200,300],
                    width: $(window).width() - 20,
                    height: 250,
                    caption: "Conductor Individual Report",
                    footerrow: true,
                    rowNum: 1500,
                    loadonce: true,
                    gridComplete: function(){
                        $("#lstReport").setGridParam({datatype: 'local'});
                    },
                    sortname: 'depot_cd',
                    sortorder: "desc",
                    loadComplete: function(data) {
                        var grid = $('#lstReport');
                        grid.jqGrid('setCaption', 'Conductor Individual Report');
                        sumFloat4 = grid.jqGrid('getCol', 'depot_cd', false, 'sum');
                        sumFloat17 = grid.jqGrid('getCol', 'DUTY_DT', false, 'sum');
                        sumFloat7 = grid.jqGrid('getCol', 'collection_tm', true, 'sum');
                        sumFloat8 = grid.jqGrid('getCol', 'route_nm', true, 'sum');
                        sumFloat10 = grid.jqGrid('getCol', 'waybill_no', true, 'sum');
                        sumFloat5 = grid.jqGrid('getCol', 'actual_km', true, 'sum');
                        sumFloat6 = grid.jqGrid('getCol', 'schedule_km', true, 'sum');
                        sumFloat11 = grid.jqGrid('getCol', 'netincome', true, 'sum');
                        sumFloat12 = grid.jqGrid('getCol', 'basicfare', true, 'sum');
                        sumFloat13 = grid.jqGrid('getCol', 'bus_type_cd', true, 'sum');
                        sumFloat15 = grid.jqGrid('getCol', 'seat_capacity', true, 'sum');
                        sumFloat16 = grid.jqGrid('getCol', 'vehicle_no', true, 'sum');
                        sumFloat18 = grid.jqGrid('getCol', 'ipkm', true, 'avg');
                        sumFloat17 = grid.jqGrid('getCol', 'fci', true, 'avg');
                        sumFloat19 = grid.jqGrid('getCol', 'Loadfactor', true, 'avg');
 
 
                        grid.jqGrid('footerData', 'set', { depot_cd: 'Total', DUTY_DT : '', condName:'', collection_tm: '', route_nm: '', waybill_no: ''
                            , actual_km: sumFloat5,schedule_km: sumFloat6,netincome: sumFloat11, basicfare: sumFloat12, bus_type_cd: ''
                            , seat_capacity: sumFloat15,vehicle_no: '',ipkm:sumFloat18,fci:sumFloat17, Loadfactor:sumFloat19});
                    }

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
74 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information