Extending Kendo Grid default grouping - asp.net-mvc-4

How can I implement some operations after kendo finishes grouping? For example, I am displaying some values based on countries, states, cities, etc. After grouping by those columns I would like to sum the values and display the total after each grouping group.
Also, how can I persist the columns state after grouping? For example, if I hide columns and then I decide to group by another column, the state gets refreshed (All columns will be displayed again). Is there a way to maintain the hidden columns after kendo finishes grouping by another column?
Thanks a lot!

1.After grouping the dataSource change event and grid dataBound are fired. In it you can use dataSource.group() method to get grouping infromation and use it like so:
function onDataBound(e) {
var gr = e.sender.dataSource.group();
//some operations on the gr variable.
}
Unfortunately it is not possible to check what exacly change in dataSource it was (grouping, filtering etc).
Better option is to use kendo aggregating mechanism to it. I recommed to try it first. Check this demo to see how it works.
2.Here is another demo I've prepared for you in which you can hide column using column menu and then group it. Hided columns remain hided after it. Can you reproduce your issue in that example if you still have problem with it?

Related

Winforms UltraGrid Infragistics grouping by two columns

I’m working on a WinForms vb.net app where you can see a Grid like the one shown in the picture attached and what I need to do is to group by the first two columns (“Grupo” and “Area”).
As you can see in the picture my SQL select statement returns many same “Grupo” and “Area” with different “identificacion” (the last visible column) and the way I would need to present it is more or less the same you can currently see in the picture but with something like for example a + sign at a side which when you press it expands and shows all the complete list of rows and columns (ungrouped) but one row for every different “identificacion”.
I’ve managed to do an approach with SortedColums with the next:
ulgListaSel.DisplayLayout.ViewStyleBand = Infragistics.Win.UltraWinGrid.ViewStyleBand.OutlookGroupBy
Dim band As UltraGridBand = ulgListaSel.DisplayLayout.Bands(0)
Dim sortedColumns As SortedColumnsCollection = band.SortedColumns
sortedColumns.Add("c_area", False, True)
sortedColumns.Add("c_grupo", False, True)
but data is not being displayed the way I’m looking for.
What I get with the code below is shown in figure 2 but you will see that only "Area" colum is shown before expanding and as a default I need all columns with same value to be shown (everythings except "identificacion").
By the way, I’m using UltraGrid v14.2
Thanks in advance.
If I follow you here correctly, you would like to have a group for each row, because the only differences are in the "identificacion" column values? Or you would like to see all the values in the groupByRow, except the "identification", and having only one group?
In the second case you would end up with only one group having the all of the column values there.
In both cases you could create and add a new unbound column in the InitializeLayout event of your UltraGrid, using the root band (0) columns collection, afterwards in the IntializeRow event populate the values of that new column based on your requirements, either using the values of all of the cells (to end up with the same number of groups as the number of differences in the "identificacion" column), or concatenating the values of all of the columns, without the ones in "identificacion", which would end up with a single group only at end.
Also once you do that, you would have to use again the InitializeLayout event of your UltraGrid, and Group by the UltraGrid, by the newly populated Unbound column, by adding it to Sorted Columns, using the same approach that was used for adding the other columns there.

How to display filtered data rows as a tooltip in Tableau Public?

Noob here, I have a table with different entries (rows) per different (repeating) regions.
I'd like to be able to display the data rows filtered - matching that particular region thanks - so I get those particular fields related to each region as a tooltip on a map. (I know how to build the map)
Thank you
Just dragging the fields you want to Details or Tooltip is not doing the trick?
Putting a measure on a shelf (other than filter shelf) includes that field in the visualization query results -- i.e. applies the chosen aggregation function to yield an aggregate result value for each partition of the data (as specified by the unique combination of dimensions)
Putting a dimension on a shelf (other than the filter shelf) also includes that field in the query results, but since the dimensions define how data rows are partitioned, it can affect the level of detail of the query. You'll notice this often as suddenly getting many more marks in your visualization after you add a dimension to a shelf. If you are familiar with SQL, dimensions define the fields that follow the GROUP BY keyword.
EDIT
Thanks for the addition, #AlexBlakemore. I've never said dragging a dimension would not work, only that it wouldn't work as the OP wanted it to (basically the same as you're saying).
And though everything you said (above) is true, it's particularly not exact when it comes to maps. Yes, dragging a dimension will further partition the data, but it will not create additional marks on a map (unless it has also geographical properties). Rather, the tooltip will get the first occurrence of that dimension, and display data for that only. For instance, if you drag "Product" to details, and the possible values are "Bread", "Coffee" and "Milk", it will probably just show "Product: Bread", and the measures for "Bread" only. So yes, it will partition, but no, it won't create additional marks.
Back to OP problem. What I believe you want is a tool tip with all values of the dimension (in my poor example you'd like to see "Bread, Coffee, Milk"). Tableau does not have functions to aggregate strings yet, so it's hard to do so.
What I would suggest is to create a separate sheet, and just drag the dimensions and measures you want to rows. Then put it side by side with the map on a dashboard, and use the map as a filter. Then, when you click on a country/region/city, you'll see the data of that region on the other chart.
Refer to: http://kb.tableausoftware.com/articles/knowledgebase/creating-filter-actions-dashboards
or https://www.tableausoftware.com/learn/tutorials/on-demand/authoring-interactivity

Turning Off Grouping In ObjectListView Turns Of Sorting

I am struggling to find information on a lot of small issues I'm starting to come across since recently integrating the ObjectListView into my application. I must admit, I love the control and it takes a lot of work away from me by having the control pretty much do everything that I need.
However, amongst a few issues that I've come across thus far, one is the fact that if I turn off grouping for individual columns it no longer allows me to sort these columns.
For example, my ListView control has an ID, Summary, Location, etc., etc. I currently run grouping on the ID because I attach a unique footer against every ID and it looks good. But, when I click on Summary, or Location it then groups all items by Summary or Location and therefore I end up with the group header but no footer anymore because the footer no longer corresponds with the ID.
What I want to achieve is to allow the user to click on any other column, but still maintain the group by ID and thus keep the footer against each item. I only want the items to sort, not group, but as mentioned, when I turn off the grouping against each column, it turns off the sort function.
UPDATE
Basically, looking at the screenshot below, I want to be able to click on the Priority Column Header (for example) to sort the list of object by Priority, but still maintain the Group By Ticket (with the Group Footer details). And basically be able to click on any Column header to sort the list but keeping the grouping by Ticket.
I have intercepted the OLV_BeforeCreatingGroups event to add:
e.Parameters.GroupByColumn = Ticket_ID
This now seems to maintain my grouping by Ticket no matter what Column header I click on, but I now loose the sort functionality.
Try setting AlwaysGroupByColumn to be the TicketId column. That will do the trick :)
Second attempt:
Thanks for the screenshot. I think I understand what you want. You are hoping that clicking on the header will sort the groups themselves. That's not the default behaviour, which is to sort the rows within each group.
To do what you are asking:
Listen for BeforeCreatingGroups event and fill in the GroupComparer property on the event argument block. This comparer controls the ordering of the groups.
The default group order is based on OLVGroup.SortValue. So you could install a GroupFormatter delegate and change the SortValue for each group so they are ordered in the manner you want.
In either case, you will need to use PrimarySort and PrimarySortOrder to know which column the user last clicked.

How to use query for grid\enhancedGrid?

I want to sort information in a dojo EnhancedGrid (connected to database through JsonRestStore). I know dojo grids provide functionality to sort based on a single column. However, in my grid, one column contains combined information from multiple fields (e.g., last name, first name, email, age) of database table. Is there a simple way to sort the grid or the data in the store based on a single filed in database table (e.g., last name)?
It seems I can use "query" to change the view of the store (grid is a view of the store if I understand correctly), but I don't understand how to write a query to do that. Can anyone give me more information about the syntax of using query or how to solve this issue?
Thank you!
It looks like you have to use what is called a comparatorMap for customized grid sorting.
here's one example :
http://www.ibm.com/developerworks/web/library/wa-aj-dojogrid/index.html
(look for the section 'Listing 15. Customize the sort function of Dojo
Grid')
inside the comparator map function is where you would convert the strings to
numbers and make the numeric comparison.

Grid Default Grouping after regrouping

I have a Grid with Grouping feature. I have set the "groupField" config to the column on which I want grouping. So when the page get load , Grid shows the grouped columns.and it is working fine.
for my requirement, I have not added the column [on which I am doing grouping] to the Grid. So the Grid doesn't show the Grouped column.
so the scenario is like.
if eg.
Grid with 5 column [Name, Email,Status,address,city]
currently displayed column= 4 [Name,Email,address,city]
Grouped column= 1 [status]
Now My Query is, out 4 [currently displayed ] column if, I changed the grouping to "city", [remember, on page load we have grouped Grid data, since I have set "groupField=status" in store] how will I go back for the default grouping [i.e. Grouping on status column]?
Note: The column "status" is not displayed to Grid, there is no header option from which I can change the Grouping.
Hope I am able to explain well here.
You can create button which will turn on grouping by status like in Ext JS example (there is only clearing, but you can do grouping as well).
Another possibility is to create handler on beforeload event in store, and check if there is any grouping turned on - if not turn on grouping by status. Then you can't turn off grouping.