Disable single key input in flex - sorting

I have an AdvancedDatagrid built up dynamically basing on xml data retrieved from http services.
The last row contains columns totals and to simulate its footer behavior it has been foreseen a custom sortFunction, but it doesn't works for multiple columns sorting.
Since I don't need multiple columns sorting, I preferred to:
set adg.sortExpertMode = true;
extend sortItemRenderer in order to hide the number indicating the sort order and so to avoid user to think multiple sort is possible
Now, my problem is that if a user presses CTRL key and click on 1+n column, the standard adg class foresees the multiple sorting. So I thought I would be possibile to catch the pression of CTRL and to eliminate its effect.
Below the code
private function keyHandler(event:KeyboardEvent):void{
if (event.ctrlKey == true){
event.stopImmediatePropagation();
}
}
It doesn't work, is there a way to make it possible??
THanks in advance!
Enrico

Related

tabulator filter: ungroup filter results

in my tabulator table I group specific rows. When I load the page I keep the groupings closed, so that the user can open those grouping he is interested in. (see attached screenshot)
But I would like to automatically open the groupings, when the user applies a filter to any column of the table. (because in this case I want him to see the results on first glance and I do not want him to open the grouping manually) Do you know how I can set up this specific requirement?
Open grouping when applying a column filter in tabulator js
Thank you very much in advance.
Best regards
To check when the table is filtered you can use the dataFiltered callback, you would need to check through the filters passed into the callback to make sure that there are filters actually applied before carrying out your app logic.
var table = new Tabulator("#example-table", {
dataFiltered:function(filters, rows){
//filters - array of filters currently applied
//rows - array of row components that pass the filters
},
});
You could the use the getGroups function to return an array of the Group Components for the table, and the itterate through the list and open the groups using the show function:
table.getGroups().forEach(function(group){
group.show();
});
I hope that helps,
Cheers
Oli :)

Why is free-jqgrid not resetting row ids after GridUnload?

The Problem
I have a very complex, rather outdated jqgrid implementation that I'm upgrading to the latest free-jqgrid and we're having an issue in that after clearing the grid with unload, when we re-initialize the grid, the row ids are higher than they should be to start.
They seem to still be incrementing and not starting again. Are there some global counters I need to clear out to have the grid completely clear itself before we re-render it?
Grid Clear
if ( this.timesheet_grid ) {
this.timesheet_grid.grid.jqGrid( 'GridUnload' );
this.timesheet_grid.grid = null;
this.timesheet_grid = null;
Rows after GridUnload has been run
Shows an id like jqg56
Stuff I've Tried Since Posting
GridDestroy
clearGridBeforeUnload
SOLUTION
As #Oleg has suggested i simply needed to set the id attribute manually when processing the grid data.
I see that your incorrectly understand the meaning of rowids and the requirements for input data. I'm wonder especially about the suggestion of Tony to reset $.jgrid.guid. I find the suggestion very bad because it looks like a solution, but it can produce more seriously problems as the problems, which are solved!
First of all, it's important to understand what is rowid. Rowid is the values of id attribute of the grid rows: the id values of <tr> elements of the grid's body (see here). The rowid are used as a parameter of almost all callbacks and events of jqGrid. Because of that jqGrid must assign id attribute to every row and the input data of the grid have to contain rowid information! The existence of rowids is critical for working jqGrid. Only because of that jqGrid generates unique rowids in case of wrong input data. Alternative for generation of ids would be preventing creating the grid at all.
jqGrid tolerates the error with specifying the rowids in input data only for some simple grids, where one need just display some simple data and one never need to use rowids. If you use ids then you should fix the problem only in one way: you have to fix your input data. You can for example include id property with unique value in every element of input data. You should take in consideration that no id duplicates exist not only in the grid but on the whole HTML page. It's strictly recommended to use idPrefix option with unique value for every grid always if your HTML page have more as one grids (inclusive grid with subgrids).
Resetting of $.jgrid.guid is very dangerous and it can break functionality of jqGrid because of creating elements with duplicate id values. The property $.jgrid.guid is global. It's common over all grids and subgrids on the page. Simple subgrids scenario will produces id duplicates after you manually reset $.jgrid.guid. It will be used inside of $.jgrid.randId() method used in many places of jqGrid code. For example, the method addRow used by inlineNav uses the method.
I repeat my suggestion more clear once more. If you uses rowids or if the values of rowids are important for you in some way then you have to include id property to every item of input data. If some other property has already an unique value then you can add key: true in the corresponding column of colModel (one can use key: true in only one column). Alternatively, you can add prmNames: { id: "myId" } if myId property of input data contains unique rowid instead of default id property.
jqGrid uses common counter in order to be a sure that there will be no duplicate values when a build in id generator is used.
To reset the value you will need to set the guid parameter to 1 - i.e
$.jgrid.guid =1;
after you unload the grid
If the solution is based on the knowing the behavior of the product, then this is a good solution.
If we try to solve the problem, without to knowing the behavior - it is a dangerous solution.
It is very easy to say - this is bad solution and it is very very dangerous to use this solution - so my question is:
What is happen with the counter if the user reload the page under some conditions?
The answer is: the counter is reset and we go to the same situations which are described in the above answer.

Remove all the rows of handson table

I am new to handsontable.
My handsontable rows are readonly.
I wanted to remove all rows of handsontable on a button click.
Please help me.
Do update with empty dataset:
handsontableInstance.updateSettings({
data : []
});
This removes all rows (and leave header if there is some).
There are many ways to "remove" all rows. For example, one, and the easiest, would be to empty your data array. So say that you initialized your HOT instance with the data field as array dataArray. Your button would only need do:
$("#buttonId").click(function() { dataArray = [];})
That would be the easiest way but of course you'd be bypassing HOT. This means that if your application gets more complex and you rely on handlers such as afterRemoveRow, then this method will bypass them. In this latter case, you'd want to use the hot.alter() method as follows:
hot.alter('remove_row', 0); // would remove the row at index 0;
With this I am assuming you know how to use a for loop that could iterate through all rows and remove them, one by one. An expensive operation but it would ensure all the proper handlers get called.
tableInstance.clear()
Clears the data from the table (the table settings remain intact).
refer to the
doc

Sorting the values in a listbox when using an expression in the sort tab in Qlikview

I want to know if anyone knows how to sort the values in a listbox in Qlikview, when one is forced to have an expression in the sort tab?
I had to use the same expression from the general tab in the sort tab
if(datakilde='Aarlig', Aktivitetsnavn)
Otherwise the listbox didn't show the associated values (from a selected value from another listbox) in the top of the listbox - which aren't very user friendly.
But as a consequence the sorting in alphabetic order is no longer works...
(And I had to have an expression in the general tab, becausecI only need a subset of the loaded data).
(I also tried with the option auto ascending in the state box under the sort tab).
See my sort tab below.
Kind Regards Maria
There are multiple solutions on this, but I think the correct one, would be to create a field in your datamodel, that contains just the values that need in the listbox.
Listboxes are not very good at filtering data. So take your if statement, and put it into the source table:
if(datakilde='Aarlig', Aktivitetsnavn) as Aktivitetsnavn_2
Then you don't have to struggle with filtering data in listboxes and your sorting will be correct.
i had similar problem while sorting a listbox with values filtered by an expression. I gave up on filtering in listbox and filtered in my load script. After that i was able to sort properly.
A solution for a similar situation I just had was the following:
I've loaded all Items that i needed sorted & filtered out in a separate table, for example:
zones:
LOAD * INLINE [
zone, **zone_order**
zone A, 1
zone D, 2
zone C, 3
zone B, 4
];
I've added my zone in the filter and in the Sort tab, i've chosen to sort by expression: zone_order, and that's it!

how can I get the count of matches for filters of jqgrid

I have pulldown select box for filtering the jqgrid (not using the builtin navbar, and data is local). I'd like to grey out the ones that have no matches in the grid.
Is there a way to perform the query to just get the count without updating the ui rows so I can initialize/update the pulldown to enable only those with matches (or even better to supply the number of matches in the menu)
EDIT:
To clarify I want to disable/greyout my filter menu items not the table row items
Internally jqGrid uses $.jgrid.from method to apply the filter to the data. What you want to implement it's probably not just getting the counts because you wrote:
I'd like to grey out the ones that have no matches in the grid.
Nevertheless all want you want is possible to implement. You will have to write some JavaScript code which uses $.jgrid.from($("#list")[0].p.data) for initialization. Then you have to construct the query using methods like contains, lessOrEquals, andNot, orNot and so on. Then you should apply the query with respect of var queryResults = query.select();. If you examine ids in the queryResults you can make gray all items which are not in the set.
I recommend you to read and to debug the addLocalData method of jqGrid and which contain all what you need. Moreover I recommend you to set breakpoint on the line and examine match and results variables. It this is not simple of cause, but if you need some individual solution you have to invest time in it.
UPDATED: I though more about the described problem. My recent answer with the demo demonstrate how you can solve your problem.

Resources