This is a migrated thread and some comments may be shown as answers.

Grid Aggregates in Batch Mode

5 Answers 245 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Lee asked on 13 Feb 2016, 04:07 PM

I have a grouped Grid in batch mode.  My aggregates aren't refreshing as edits are made to the aggregated data until after a .saveChanges is performed.  I want the aggregate to update as soon as the focus leaves a cell that is aggregated.

My Columns look like this:

    columns.Bound(c => c.Period1)
       .HeaderTemplate("<a>" + @title1 + "<br>" + @title2 + "</a>")
       //.ClientGroupHeaderTemplate("#= sum #")
       .ClientGroupFooterTemplate("#= sum #")
       .ClientFooterTemplate("#= sum #")
       .Filterable(false)
       .Width(100);

My Datasource is configured as such:

    .DataSource(dataSource => dataSource
    .Ajax()
    .AutoSync(false)
    .Aggregates(aggregates =>

    {
       if (Model.Count() > 0) { aggregates.Add(p => p.Period1).Sum(); }
       //more aggregate properties here

})
.Batch(true)
.ServerOperation(false)
.Events(events => events.Error("error_handler"))
.Group(groups => groups.Add(p => p.ProjectType))
.Model(model =>
{
model.Id(prop => prop.ID);

//other model properties here

})
.Create(create => create.Action("CreateManpowerProjectEstimates", "Manpower"))
.Read(read => read.Action("ReadManpowerProjectEstimates", "Manpower"))
.Update(edit => edit.Action("UpdateManpowerProjectEstimates", "Manpower"))
.Destroy(delete => delete.Action("DestroyManpowerProjectEstimates", "Manpower"))
.PageSize(20)
)

 

5 Answers, 1 is accepted

Sort by
0
Dimiter Topalov
Telerik team
answered on 17 Feb 2016, 09:00 AM
Hello Lee,

To achieve the desired behavior, you can attach a handler to the Save() event of the Kendo UI Grid and call the refresh() method in the corresponding function:

...
.Events(e => e.Save("updateValues"))
...
 
<script>
function updateValues(e){
e.sender.refresh();
}
</script>

I hope this helps.

Regards,
Dimiter Topalov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Lee
Top achievements
Rank 1
answered on 19 Feb 2016, 02:54 AM

That worked like a charm for making the aggregates recalculate but after putting in the e.sender.refresh() the grid cell looses focus.  The user would have to pick up the mouse and position it on the next cell after every edit.  This isn't feasible either.  I've been trying to figure out how to determine what cell has focus before the save event is triggered and then after calling the refresh set focus back on that cell or the next cell since most likely what triggered the save is the user tabbing to the next cell.  This is what I've tried:

var cell = $(this).closest("td");

var colIdx = grid.cellIndex(cell);

As I put watch points in the client script and step through the colIdx is always returning -1 regardless of what cell had focus.

0
Nikolay Rusev
Telerik team
answered on 23 Feb 2016, 03:52 PM

Hello Lee,

 

We are not sure where you are attempting to get the edited cell. If you do that in the save event handler and you are using incell editing it should be possible:

 

save: function(e) {
 var index = e.container.index();
 console.log(index);
 this.refresh();                          
},

 

Example - http://dojo.telerik.com/@rusev/uwUGa

 

Regards,
Nikolay Rusev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Lee
Top achievements
Rank 1
answered on 03 Mar 2016, 06:09 PM

That gives me the index of the column I'm not having any luck putting focus back onto the cell.

function updateValues(e) {
var grid = $("#gridResourceManagerInput").data("kendoGrid");
var index = e.container.index();
console.log(index);
//alert(e.sender.text());
e.sender.refresh();
var cell = $("#gridResourceManagerInput td:eq(" + index + ")");
grid.current(cell);
grid.table.focus();
grid.editCell(cell);
}

0
Nikolay Rusev
Telerik team
answered on 07 Mar 2016, 09:58 AM

Hello Lee,

 

Can you demonstrate this in a isolated runnable example for better understanding? Thus we'll be able to debug it locally and assist you further.

 

Regards,
Nikolay Rusev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Lee
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Lee
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or