Customize Filtering Issue

Hi,

I’m disturbing you for a problem that i’m not able to solve.

What i’d like to do is realize a filtering issue in Grid with “(Tutte)” in filter box, instead of blank, to unfilter the grid column and adding as second option “(Vuote)” to filter and list only the blank (or empty) cells in the column, like in Excel.

To make this issue i modified code in dhtmlx.js on dhtmlXGridObject.prototype._loadSelectOptins

This is the code:
dhtmlXGridObject.prototype._loadSelectOptins=function(t,c){
var l=this.collectValues©;
var v=t.value;t.innerHTML="";
------------------- my customization -------------------------------
t.options[0]=new Option("(Tutte)","");
t.options[1]=new Option("(Vuote)",“null”);

var f=this._filter_tr?this._filter_tr[c]:null;
for (var i=0;i<l.length;i++)
	t.options[t.options.length]=new Option(f?f(l[i]):l[i],l[i]);
t.value=v;

}

My two personal Options are regularly shown in filter box and (Tutte) option runs correctly unfiltering the column. The problem is my second Option. If, for istance, i write a real value present in the column, the filter runs filtering the cells with that value but if i write “” the issue is unfiltering the column as previous (Tutti).
If i write null no rows are selected while i’d like to list rows with empty cells in the filtered column.

i’m disperating asking your help. I don’t know how to make application recognizing the empty cells.

Many thanks as always,

Unfortunately it’s not available to filter the grid by the empty values.

I found a solution redefining the filter logic through:

getFilterElement(column)._filter …

and it works fine with #select_filter. Now i want to use #combo_filter that is more flexible but i’ve tre basic problems:

  1. the customization that i indicated in my previous post doesn’t run (the first item of combo is simply a blank row).

  2. the customization of filter logic with getFilterElement(column)._filter seems not running.

  3. i’d want to fill the combo with checboxes for the various option to obtain a kind of multiselect filter to use in my filter logic (a filter excel like), but i don’t know how fill the combo with checboxes and in which event.

Could you help me ?

Please i need help.

Hi everybody,

I’m continuing to try to build a customized filtering methods for grid.

I’m trying to redefine your original function:

dhtmlXGridobject.prototype._in_header_select_filter

but i’ ve a problem. I need for my code the reference to the grid that contains the filter, to call collectValues function. I thought to use “this” for reference to grid but it doesn’t run in this context because i always receive an error: “Object doesn’t support this property or method”. I f i use the real name of my Grid, code runs correctly, but of course i’ve to use the contextual name depending on filter that i select.

Please i need a suggestion, thanks.

For a combo you need to use the following function:
mygrid.getFilterElement(0).DOMParent._filter = function(){}

If issue still occurs, please, provide with your actual sample of the code.

Hi Sematik,

Thank for answer but it’ not this my problem, i just discovered the function that you indicated for use with combo.

As i said in my previous post, instead, i’m using select for filtering and so i’m redefining this prototype:

dhtmlXGridobject.prototype._in_header_select_filter

that run with select and not with Combo, and so then i use: getFilterElement(column)._filter that is used with select and not with Combo.

My problem i another:
Inside the dhtmlXGridobject.prototype._in_header_select_filter, that i’m modifying i need a reference to the GRID OBJECT (i tried with ‘this’ but it doesn’t run) to call the function collectValues. I don’t know, in this context, how to get this reference.

Thanks again.

Actually “this” inside of _in_header_select_filter method do point to the grid object.

Ni Stanislav happy to talk to you again !

I tought that ‘this’ was referred to the Grid too, but, inside the function when i call the collectValues ‘this.collectValues(column)’ i have always this error:

Object doesn’t support this property or method

What’s the problem ?

Thank you.

Are you using some inline sub-functions inside of _in_header_select_filter?
While “this” will point to the grid object directly in the body of _in_header_select_filter, it will not work for sub-functions.

You may do the next

dhtmlXGridObject.prototype._in_header_select_filter=function(t,i){ var gridobj = this; ... any other code ... };

With above code, you can use gridobj in any other code, including sub-functions.

Great Stan

Of course it runs correctly ! But solved a problem there is another !

In my code, clicking on filter select i open a box to choose filters avoiding to show the default select list:
I used this code: t.innerHTML="";

in ‘dhtmlXGridObject.prototype._in_header_select_filter’ and always run correctly, but when i double click on the select the list opens the same.

I try to catch the dblclick event but it seems to happen after list opening and so i can’t avoid it. Is there some other event to catch to avoid this default list ?

Many Many thanks !

Stan

Help Help !!

Stan where are you ?

I need your help for the problem in the previous post but now there is another strange and unintelligibile problem.

in my grids i have some date column. The date are stored in DB as (Y-m-d) but i used Italian format (d/m/Y)

Column definition.
setColType (“dhxCalendar,dhxCalendarA”);
setColSorting(“date, date”);
setDateFormat("%d/%m/%Y","%Y-%m-%d");
enableSmartRedering(true);

The problem is that when i click on header to sort the column, the order is set only for a part of the column, after that the dates are not ordered.

I can’t understand ! Help me please.