IN Design Page( View)
<div class="director-dashboardProject ">
@( Html. Kendo( ). Grid<SPAN. OMS. ViewModel. SummaryView >() // Your View Model
. Name( "UsaProjectGrid")
. Columns( columns =>
{
columns . Bound( p => p. ProjectName). Format( "{0: n2}"). ClientFooterTemplate( "Grand Total:"). Width( 122);
columns.Bound(p => p.BudgetedValue).Format("{0:n2}").Width(122).ClientFooterTemplate("#= kendo.format('{0:c}', sum) #").Format("{0:c2}");
columns.Bound(p => p.ForecastedValue).Format("{0:n2}").Width(122).ClientFooterTemplate("#= kendo.format('{0:c}', sum) #").Format("{0:c2}");
columns.Bound(p => p.ActualRevenue).Format("{0:n2}").Width(122).ClientFooterTemplate("#= kendo.format('{0:c}', sum) #").Format("{0:c2}");
columns.Bound(p => p.ActualCost).Format("{0:n2}").Width(122).ClientFooterTemplate("#= kendo.format('{0:c}', sum) #").Format("{0:c2}");
columns.Bound(p => p.CommissionValue).Format("{0:n2}").Width(122).ClientFooterTemplate("#= kendo.format('{0:c}', sum) #").Format("{0:c2}");
columns.Bound(p => p.MarginValue).Format("{0:n2}").Width(122).ClientFooterTemplate("#= kendo.format('{0:c}', sum) #").Format("{0:c2}");
})
. Events( events => events. DataBound( "DataBound"))
. DataSource ( dataSource => dataSource
. Ajax( )
. Events( events => events. Error( "error_handler"))
. Aggregates( aggregates =>
{ /// Calculating sum for all the rows
aggregates . Add( p => p . BudgetedValue). Sum( );
aggregates . Add( p => p. ForecastedValue). Sum( );
aggregates . Add( p => p . ActualRevenue ). Sum( );
aggregates . Add( p => p . ActualCost ). Sum( );
aggregates . Add( p => p. CommissionValue ). Sum( );
aggregates . Add( p => p. MarginValue ). Sum( );
})
. Read( read => read. Action( "GetUsaProjectSummary", "SummaryView "). Data( "ItemFormValues")) // Action name and Controller Name
)
)
</div >
In Controller:
public ActionResult GetUsaProjectSummary( int month, [DataSourceRequest] DataSourceRequest request)
{
int year = Convert.ToInt32( System. DateTime. Now. Year);
List<SummaryView > projectdetail = new List<SummaryView >();
projectdetail = ManagementService . Getdata( month, year); // Getting Data from your service class
IQueryable<SummaryView> res = projectdetail.AsQueryable<SummaryView>();
DataSourceResult res1 = res. ToDataSourceResult( request);
return Json( res1, JsonRequestBehavior. AllowGet);
}
<
@
{
columns.Bound(p => p.BudgetedValue).Format("{0:n2}").Width(122).ClientFooterTemplate("#= kendo.format('{0:c}', sum) #").Format("{0:c2}");
columns.Bound(p => p.ForecastedValue).Format("{0:n2}").Width(122).ClientFooterTemplate("#= kendo.format('{0:c}', sum) #").Format("{0:c2}");
columns.Bound(p => p.ActualRevenue).Format("{0:n2}").Width(122).ClientFooterTemplate("#= kendo.format('{0:c}', sum) #").Format("{0:c2}");
columns.Bound(p => p.ActualCost).Format("{0:n2}").Width(122).ClientFooterTemplate("#= kendo.format('{0:c}', sum) #").Format("{0:c2}");
columns.Bound(p => p.CommissionValue).Format("{0:n2}").Width(122).ClientFooterTemplate("#= kendo.format('{0:c}', sum) #").Format("{0:c2}");
columns.Bound(p => p.MarginValue).Format("{0:n2}").Width(122).ClientFooterTemplate("#= kendo.format('{0:c}', sum) #").Format("{0:c2}");
})
})
)
)
</
In Controller:
{
List<
IQueryable<SummaryView> res = projectdetail.AsQueryable<SummaryView>();
}
No comments:
Post a Comment