Auto filter (excel type) in listgrid

Hi,

We are using tree grid in the left side and list grid in the right side. When a node is clicked in tree grid, the data for the clicked node will be fetched from server and will be populated in the list grid(using XJASONDataSource). In the right side list grid, the requirement is to have all the filter editors as “Select” and the values should be unique values of that perticular columns. It is like in microsoft excel, auto filter feature( in excel data –> filter –>Autofilter). Please let us know how to populate the values for filter editor based on the values of the grid columns. I used the below lines to poulate the filterfield values dynamically. But nothing happened.

<code>
itemList.setFieldProperties(“endcustname”,{
filterEditorType :“SelectItem”,
filterEditorValueMap:{“FirstValue”:“FirstValue”,“SecondValue”:“SecondValue”}
}
</code>

itemList is ListGrid with 11 columns/fields and endcustname is one of them

The best way to approach this is probably via an override of getFilterEditorValueMap that dynamically retrieves the list of valid values from the dataset (via listGrid.data.getProperty(“fieldName”).getUniqueItems()).

getFilterEditorMap is not getting called

I am attaching the code for creating the listgrid. I have added the getFilterEditorMap at both field level and list grid level but no use. Please help in solving this. I do not see any thing developer console.

isc.ListGrid.create({
	ID:"itemList",
	dataSource:"orderDS",
	useAllDataSourceFields:true,
			width:"730",			
			height: "100%",
	showFilterEditor: true,
    canDragRecordsOut: true,
    selectionType: "single",
	canEdit:true,
    modalEditing:true,
	canDragRecordsOut:true,
	useCellEvents:true,
    editEvent: "click",
    editOnFocus:true,
    //overflow: "scroll",
    autoFetchData: false,
    dragDataAction: "move",
    alternateRecordStyles:true,
    wrapCells:true,
    wrapHeaderCells:true,
    cellHeight:30,
    autoShow: false,  
    headerHeight:40,    
    booleanImageWidth:13,
    booleanImageHeight:13,
      
    fields: [
            {name:"selection" ,title:"Selection ", type:"boolean",canEdit:true,width:100,filterEditorType:"select"},    
            {name:"dealId",ID:"dealIdField",wrapCells:true,width:100,filterEditorType:"select",
                formatCellValue: function (value, record) 
                    {
                        return "<a href=caseOverview.html?caseId="+value+">"+value+"</a>";
                    },
                getFilterEditorMap : function(fieldName) 
                {
                    isc.logWarn("inside getFilterEditorMap for "+fieldName);
                    return itemList.data.localData.getProperty(fieldName).getUniqueItems ();
                }                
            },    		    
		    {name:"endcustname",width:100,ID:"endcustnameField",title:"End </br> customer name",canEdit:false,wrapCells:true,filterEditorType:"select"},
		    {name:"casenum" ,title:"Case #", width:100,canEdit:false, filterEditorType:"select"},
		    {name:"casecreatedate" ,width:100,title:"Case creation </br>date",canEdit:false,filterEditorType:"select"},
		    {name:"status" ,title:"Status",width:100,canEdit:false,filterEditorType:"select"},
		    {name:"leadcountry" ,title:"Lead country",canEdit:false,width:100,filterEditorType:"select"},
		    {name:"mccode" ,title:"Mc code",canEdit:false,width:100,filterEditorType:"select"},
		    {name:"totaldiscamt" ,title:"Total discount </br>amount",canEdit:false,width:100,filterEditorType:"select"},
		    {name:"systemcasetype" ,title:"System case </br>type",canEdit:false,width:100,filterEditorType:"select"},
		    {name:"sysconfidence" ,title:"System </br>confidence",canEdit:false,width:100,filterEditorType:"select"},
		    {name:"dataminingscore" ,title:"Data mining </br>score",canEdit:false,width:100,filterEditorType:"select"},
		    {name:"alarms" ,title:"# Alarms",canEdit:false,width:100,filterEditorType:"select"},
		    {name:"usermodifieddate" ,title:"User modified </br>date",canEdit:false,width:100,filterEditorType:"select"},
		    {name:"events" ,title:"# Events",canEdit:false,width:100,filterEditorType:"select"},
		    {name:"archivedcase" ,title:"# Archived case",canEdit:false,width:100,filterEditorType:"select"}
    ],
    
    recordClick: "caseDetailsLeft.setData(record);caseDetailsRight.setData(record);",
    cellContextClick:"return itemListMenu.showContextMenu()",
    cellClick: function (record, rowNum, colNum) {
    if(colNum==0)
    record.selection=!record.selection;
    },
    hoverWidth: 100,
    getDragTrackerTitle : function ()
    {
        return "<font color='red'>" 
        +itemList.getSelectedRecord().dealId+" : " 
        + itemList.getSelectedRecord().endcustname+ " : " 
        + itemList.getSelectedRecord().casenum+"</font>";
    } ,
    getFilterEditorMap : function (fieldName) {
    isc.logWarn("inside getFilterEditorMap for " + fieldName);
    return itemList.data.localData.getProperty(fieldName).getUniqueItems ();
    }
});

The API is actually getFilterEditorValueMap (docs were correct, my post was not).

dynamically setting the filterValueMap based on the grid data

Hi,

I need to set the filterValueMap dynamicaly based on the data in the grid. Ex:

I have a grid with three columns, first name, last name and sex

the data is like this:
FirstName SecondName Sex
Ravi Kumar Male
Shashi Kumar Male
Rupesh Kumar male
Ravi Shankar Male.

Here the filter value for each column should be
{Ravi,Shashi,Rupesh},{Kumar,Shankar},{male}

I get the values of the grid from some url.

If i use getFilterEditorValueMap, this is called only when the list grid is been created, and when i try to set the values for filterEditorValueMap using listGrid.setProperty or listGrid.field[1].setProperty or listGrid.setFieldProperty, nothing is getting changed. I tried even redawing the list grid so that new values are shown in the filter. Please help me in resolving this.

Yeah we understand the requirement.

Adding the following code to this example works as expected:

    showFilterEditor:true,
    getFilterEditorValueMap : function (field) {
        return this.data.getProperty(field.name).getUniqueItems();
    },

At least two obvious things wrong with your code (from previous example):

  1. getFilterEditorValueMap is passed the field, not the field name
  2. data.localData is an internal cache, don’t access it

Not working as expected

This is bringing the values to filterEditor. But when the data is changed in the grid (new set of data is populated through datasource), filterEditor values are not getting changed. The data in the grid is fecthed by click of a leaf in a tree grid through a servlet. It seems, the filterEditorValues are not getting refreshed once data changes in the grid.

is there any method to set the valueMap for the filterEditors once data is fetched from datasource?

Ah, ok. Since you want newly calculated valueMaps on every field, the easiest approach is just to re-initialize the filterEditor like so:

countryList.setShowFilterEditor(false);
countryList.setShowFilterEditor(true);

.. right after providing new data.

javascript error

I am facing few issues.

  1. I am using XJASONDataSource, and listGrid.data.getProperty(field.name) is giving java script error.
    14:00:37.219:MUP1:WARN:Log:Error:
    ‘‘itemList.data.getProperty(…)’ is null or not an object’
    in http://localhost:8080/dcs/
    at line 483
    updateFilters(field=>Obj{name:dealId})
    [o]DCSListGrid.getFilterEditorValueMap(field=>Obj{name:dealId})
    RecordEditor.getEditorValueMap(_1=>Obj{name:dealId}, _2=>Obj)
    ListGrid.getEditItem(_1=>Obj{name:dealId}, _2=>null, _3=>Obj, _4=>0, _5=>1, _6=>100)
    ListGrid.getEditRowItems(_1=>null, _2=>0, _3=>0, _4=>false)
    GridBody.draw(_1=>undef, _2=>undef, _3=>undef, _4=>undef)
    Canvas.drawChildren()
    Canvas.draw(_1=>undef, undef, undef, undef, undef, undef, undef, undef)
    Class.invokeSuper(_1=>[Class ListGrid], _2=>“draw”, _3=>undef, _4=>undef, _5=>undef, _6=>undef, _7=>undef, _8=>undef, _9=>undef, _10=>undef)
    ListGrid.draw(_1=>undef, _2=>undef, _3=>undef, _4=>undef)
    Class.invokeSuper(_1=>null, _2=>“draw”, _3=>undef, _4=>undef, _5=>undef, _6=>undef, _7=>undef, _8=>undef, _9=>undef, _10=>undef)
    Class.Super(_1=>“draw”, _2=>Obj{length:0}, _3=>undef)
    RecordEditor.draw()
    Canvas.addPeer(_1=>[RecordEditor ID:itemListfilterEditor], _2=>undef, _3=>undef, _4=>undef)
    ListGrid.makeFilterEditor()
    ListGrid.setShowFilterEditor(_1=>true)
    [a]TreeGrid.nodeClicked()
    [a]TreeGrid.nodeClick(viewer=>[TreeGrid ID:worklistTree], node=>Obj, recordNum=>2)
    TreeGrid.rowClick(_1=>Obj, _2=>2, _3=>0)
    [a]GridBody.rowClick(record=>Obj, rowNum=>2, colNum=>0)
    GridRenderer.$29y(_1=>2, _2=>0)
    GridRenderer.click(Obj, undef)
    Class.invokeSuper(_1=>null, _2=>“click”, _3=>undef, _4=>undef, _5=>undef, _6=>undef, _7=>undef, _8=>undef, _9=>undef, _10=>undef)
    Class.Super(_1=>“click”, _2=>Obj{length:2}, _3=>undef)
    TreeGridBody.click(_1=>Obj, _2=>undef)
    Canvas.handleClick(_1=>Obj, _2=>undef)
    EventHandler.bubbleEvent(_1=>[TreeGridBody ID:worklistTree_body], _2=>“click”, _3=>undef, _4=>undef)
    EventHandler.handleClick(_1=>[TreeGridBody ID:worklistTree_body], _2=>undef)
    EventHandler.$k5(_1=>Obj{type:error}, _2=>undef)
    EventHandler.handleMouseUp(_1=>Obj{type:error}, _2=>undef)
    EventHandler.dispatch(_1=>EventHandler.handleMouseUp(), _2=>Obj{type:error})
    anonymous(event=>undef)
    “var returnVal=arguments.callee.$ch.isc.EH.dispatch(arguments.callee.$j2,event);return returnVal;”

  2. The data is not getting refreshed even after the setShowFilterEditor(false) and setShowFilterEditor(true). But if i drag the layout, data is getting populated in FilterEditor. Even if i scroll the grid, data is getting refreshed. But most of the time i get java script error.

13:50:54.055:RDQ9:WARN:Log:Error:
‘Unexpected call to method or property access.’
in http://localhost:8080/dcs/
at line 1120
FormItem.focusInItem()
Class.invokeSuper(_1=>null, _2=>“focusInItem”, _3=>undef, _4=>undef, _5=>undef, _6=>undef, _7=>undef, _8=>undef, _9=>undef, _10=>undef)
Class.Super(_1=>“focusInItem”, _2=>Obj{length:0}, _3=>undef)
[o]SelectItem.focusInItem()
PickListMenu.hide(_1=>undef, _2=>undef, _3=>undef, _4=>undef)
FormItem.destroy()
DynamicForm.removeItems(_1=>Array[5])
GridBody.redraw(_1=>false, _2=>undef, _3=>undef, _4=>undef)
Canvas.clearRedrawQueue()
Class.fireCallback(_1=>Obj, _2=>undef, _3=>Array[0], _4=>[Class Canvas], _5=>true) on [Class Timer]
Timer.$in(_1=>“$ir1100”)
anonymous()
“isc.Timer.$in(‘$ir1100’)”

Please help on this.

Hi Ravin

How exactly are you populating your grid with data?
Are you providing an initial set of data as an array? When the user clicks on the treeGrid to change values how are you updating the data? Via a listGrid.setData([data array]) call, or via a call to fetchData() or filterData() on the grid, or something else (such as modifying the dataSource on the Grid)?
If you call “isc.logWarn(‘Data:’ + itemList.data)” as part of the getFilterEditorValueMap() method, what is displayed in the developer console?

The approach we suggested should work for static data supplied to the ListGrid via a setData() call but we can see how you’d get this error if you’re doing a normal dataBound fetch and then trying to call ‘getProperty()’ on the resulting ListGrid data object.
Before we get deeper into this, lets take a step back and make sure we understand your use case properly. Seeing the code to actually update the ListGrid data in response to a user-click on the tree might help.

On the second issue, the javascript error may be due to an issue which has been resolved since 6.5.1.
Can you try adding the following patch to your application and see if it resolves the issue

isc.FormItem.addProperties({
 _d:isc.FormItem.getPrototype().destroy,
 destroy:function (a,b,c,d) {
    if (this.pickList && this.pickList.formItem == this) delete this.pickList.formItem;
   return this._d(a,b,c,d);
 }
});

If this doesn’t resolve it, we may need more info to pin it down, or it may be related to the other issue.

Regards
Isomorphic Software

Hi Ravin

After posting my previous response I realized that the simplest approach in this case is probably to do the following when you need to change your grid’s data:

  • perform a direct fetch against your dataSource to get an array of results
orderDS.fetchData({[i][criteria][/i]}, "updateGridData(data)");
  • and have a function to update the grid data with this new, static data:
function updateGridData (data) {
    itemList.setData(data);

    // rebuild the filter editor to reset the set of options
    itemList.setShowFilterEditor(false);
    itemList.setShowFilterEditor(true);
}

I think this should just work, leaving the getFilterEditorValueMap() code as is.

If this approach won’t work for you, let us know and we’ll pursue it further

Regards

Isomorphic Software

java script error

Hi, I am using the jsp to get the data for my grid using XJSONDataSource. Please find the code

code to create the tree grid

isc.TreeGrid.create({
    ID: "worklistTree",
    showHeader:false,
    showResizeBar: true,
    title:"Worklist Management",
	dataSource:"workListDs",
    nodeClick: "this.nodeClicked()",
	canAcceptDroppedRecords: true,
    selectionType: "single",
    autoFetchData: true,
    confirmationValue : false,
    dropFolderSelected :null,
    selectedRecord :null,
    selectedCountry: null,
    leaveScrollbarGap:false,
    autoShow: false,
    fields: [
        {name: "Work List", formatCellValue: "record.workListName"}
    ],    
    
    folderDrop : function (dragRecords, dropFolder) {
    selectedRecord = itemList.getSelectedRecord();
    selectedCountry = selectedRecord.workListName;
    
    dropFolderSelected=dropFolder;        
        isc.confirm("Do you really want to move case number " + selectedRecord.casenum+ " from "+selectedCountry +" to " +dropFolderSelected.workListName +"?",this.moveWL);        
    },
    
    moveWL : function(confirmationValue)
    {
        if(confirmationValue==true)
       {        
        var newCategory = dropFolderSelected.workListName;
        selectedRecord.workListName=newCategory;
        selectedRecord.category = newCategory;
        orderDS.updateData(selectedRecord);
        }
    },
    nodeClicked : function()
    {    
    itemList.fetchData({workListName:this.getSelectedRecord().workListName});
    itemList.setShowFilterEditor(false);
    isc.Timer.setTimeout("itemList.setShowFilterEditor(true)",200);
    }    
    
});

isc.DataSource.create({
    ID: "workListDs",
    title:"WorkList",
    fields:[
    {name:"workListName", title:"Work List", required:true, primaryKey:true},
    {name:"parentID", hidden:"true",  type:"text", required:"true", foreignKey:"workListDs.workListName", rootValue:"root"}
],
dataURL:"workListItems.jason"
});

Please find the code for listgrid.

isc.ListGrid.create({
	ID:"itemList",
	dataSource:"orderDS",
	useAllDataSourceFields:true,
			width:"730",			
			height: "100%",
	showFilterEditor: true,
    canDragRecordsOut: true,
    selectionType: "single",
	canEdit:true,
    modalEditing:true,
	canDragRecordsOut:true,
	useCellEvents:true,
    editEvent: "click",
    editOnFocus:true,
    dragDataAction: "move",
    alternateRecordStyles:true,
    wrapCells:true,
    wrapHeaderCells:true,
    cellHeight:30,
    autoShow: false,  
    headerHeight:40,
    autoDraw: true,     
      filterOnKeypress:true,
    fields: [
            {name:"selection" ,title:"Selection ", type:"boolean",canEdit:true,width:100},    
            {name:"dealId", wrapCells:true,width:100,filterEditorType:"SelectItem",canEdit:false,
                formatCellValue: function (value, record) 
                    {
                        return "<a href=caseOverview.html?caseId="+value+">"+value+"</a>";
                    }                             
            },    		    
		    {name:"endcustname",width:100,ID:"endcustnameField",title:"End </br> customer name",canEdit:false,wrapCells:true,filterEditorType:"SelectItem"},
		    {name:"casenum" ,title:"Case #", width:100,canEdit:false, filterEditorType:"SelectItem"},
		    {name:"casecreatedate" ,width:100,title:"Case creation </br>date",canEdit:false,filterEditorType:"SelectItem"},
		    {name:"status" ,title:"Status",width:100,canEdit:false,filterEditorType:"SelectItem"},
		    {name:"leadcountry" ,title:"Lead country",canEdit:false,width:100,filterEditorType:"SelectItem"},
		    {name:"mccode" ,title:"Mc code",canEdit:false,width:100,filterEditorType:"SelectItem"},
		    {name:"totaldiscamt" ,title:"Total discount </br>amount",canEdit:false,width:100,filterEditorType:"SelectItem"},
		    {name:"systemcasetype" ,title:"System case </br>type",canEdit:false,width:100,filterEditorType:"SelectItem"},
		    {name:"sysconfidence" ,title:"System </br>confidence",canEdit:false,width:100,filterEditorType:"SelectItem"},
		    {name:"dataminingscore" ,title:"Data mining </br>score",canEdit:false,width:100,filterEditorType:"SelectItem"},
		    {name:"alarms" ,title:"# Alarms",canEdit:false,width:100,filterEditorType:"SelectItem"},
		    {name:"usermodifieddate" ,title:"User modified </br>date",canEdit:false,width:100,filterEditorType:"SelectItem"},
		    {name:"events" ,title:"# Events",canEdit:false,width:100,filterEditorType:"SelectItem"},
		    {name:"archivedcase" ,title:"# Archived case",canEdit:false,width:100,filterEditorType:"SelectItem"}
    ],
    
    recordClick: "caseDetailsLeft.setData(record);caseDetailsRight.setData(record);",
    cellContextClick:"return itemListMenu.showContextMenu()",
    cellClick: function (record, rowNum, colNum) {
    if(colNum==0)
    record.selection=!record.selection;
    },
    hoverWidth: 100,
    getDragTrackerTitle : function ()
    {
        return "<font color='red'>" 
        +itemList.getSelectedRecord().dealId+" : " 
        + itemList.getSelectedRecord().endcustname+ " : " 
        + itemList.getSelectedRecord().casenum+"</font>";
    } ,
    getFilterEditorValueMap : function (field) {
    if  (field.name !="selection")
        return updateFilters(field);
    }   
});

isc.XJSONDataSource.create({
    ID: "orderDS",
    dataFormat:"json",
    fields:[
        {name:"selection" ,title:"Selection", type:"boolean"},
		    {name:"dealId" ,title:"Deal ID"},
		    {name:"endcustname" ,title:"End customer name"},
		    {name:"casenum" ,title:"Case #"},
		    {name:"casecreatedate" ,title:"Case creation date"},
		    {name:"status" ,title:"Status"},
		    {name:"leadcountry" ,title:"Lead country"},
		    {name:"mccode" ,title:"Mc code"},
		    {name:"totaldiscamt" ,title:"Total discount amount"},
		    {name:"systemcasetype" ,title:"System case type"},
		    {name:"sysconfidence" ,title:"System confidence"},
		    {name:"dataminingscore" ,title:"Data mining score"},
		    {name:"alarms" ,title:"# Alarms"},
		    {name:"usermodifieddate" ,title:"User modified date"},
		    {name:"events" ,title:"# Events"},
		    {name:"archivedcase" ,title:"# Archived case"},
		    {name:"workListName" ,title:"# WorkList"}
		    
    ],   
    recordXPath:"/ResultSet/Result",
    operationBindings:[
        {operationType:"fetch",
         dataURL:"data.jsp"
         },
        {operationType:"add",
         dataURL:"add.jsp"
         },
        {operationType:"update",
         dataURL:"update.jsp"
         },
        {operationType:"remove",
         dataURL:"remove.jsp"
         }
    ]
 
});

function updateFilters(field)
{
        isc.logWarn("creating filter values for :"+field.name );
        var data;
        if(itemList.data.allRows!=null)
        {
        isc.logWarn("allRows");
        data=itemList.data.allRows;
        }
        else
        {
        isc.logWarn("localData");
        data=itemList.data.localData;
        }
        if(data!=null)
        {
            var uniqueValues=data.getProperty(field.name).getUniqueItems();
            isc.logWarn("Setting the uniq array " + uniqueValues + " from " + data.getProperty(field.name));
            return uniqueValues;
        }
        else
        {
            return {"":""};
        }
    
 //   }
  //  itemList.redraw();
}

Please note that even the allRows will be null.

Please sugest. Even after the patch, I am getting the same js error.

One part working, but another failing

Hi,

Thanks for the code. Data fetching and displaying the auto filter is working with itemList.data.

But when the grid is scrolled (quickly), I am getting javascript error. As you have seen, the grid has 16 visible coulmns (one hidden) and mostly, 6 columns at a time.

I think it s due to timing issue. Please suggest. (Can we block the user by not accessing for few more miliseconds so that repaint is completed?)

'Unexpected call to method or property access.'
in http://localhost:8080/dcs/
at line 1120
FormItem.focusInItem()
Class.invokeSuper(_1=&gt;null, _2=&gt;"focusInItem", _3=&gt;undef, _4=&gt;undef, _5=&gt;undef, _6=&gt;undef, _7=&gt;undef, _8=&gt;undef, _9=&gt;undef, _10=&gt;undef)
Class.Super(_1=&gt;"focusInItem", _2=&gt;Obj{length:0}, _3=&gt;undef)
[o]SelectItem.focusInItem()
PickListMenu.hide(_1=&gt;undef, _2=&gt;undef, _3=&gt;undef, _4=&gt;undef)
FormItem._d(undef, undef, undef, undef)
FormItem.destroy(a=&gt;undef, b=&gt;undef, c=&gt;undef, d=&gt;undef)
DynamicForm.removeItems(_1=&gt;Array[6])
GridBody.redraw(_1=&gt;false, _2=&gt;undef, _3=&gt;undef, _4=&gt;undef)
Canvas.clearRedrawQueue()
Class.fireCallback(_1=&gt;Obj, _2=&gt;undef, _3=&gt;Array[0], _4=&gt;[Class Canvas], _5=&gt;true) on [Class Timer]
Timer.$in(_1=&gt;"$ir331")
anonymous()
    "isc.Timer.$in('$ir331')"

Hi Ravin,
So if I understand the situation:

1: You are now now using the approach we detailed of calling ‘fetchData()’ on the dataSource and directly assigning the results of that fetch to the itemList’s data array via a ‘setData()’ call [NOT the approach of calling ‘fetchData()’ on the grid and reaching into the data object’s “localData” attribute, as in your posted code].
Is this right?
If so, it could be helpful to see your latest version of the code.

2: You have also applied the patch we suggested:

isc.FormItem.addProperties({
 _d:isc.FormItem.getPrototype().destroy,
 destroy:function (a,b,c,d) {
    if (this.pickList && this.pickList.formItem == this) delete this.pickList.formItem;
   return this._d(a,b,c,d);
 }
});

but you are still seeing the ‘Unexpected call to method or property access.’ error, correct?

Can you tell us exactly what steps you take to get the error? We just can’t reproduce the error on our end and the patch above seems like it should resolve the issue based on the stack trace, so as much detail as you can give us would be helpful…
For example:

  • 1: select a record from the tree grid (record is populated with approx 100 rows)
  • 2: show the drop down list for the “deal ID” field (it shows 10 entries)
  • 3: with the drop down list still showing, drag scroll the itemList body horizontally to the right edge
    [result - javascript error]
    Or whatever your set of steps are

So far we’ve tried to reproduce this by taking the code you posted and running it in the 6.5.1 environment both IE and Firefox.
We had to modify the dataSources to be client-only dataSources with test data to make the code into a workable test-case.
We tried running the code as written, and also tried it having modified nodeClicked() / updateFilters() to take the approach we suggested of performing a data-source fetch and using ‘setData()’ to pass the data to the grid, all with no luck reproducing the error.

Also

  • which browser(s) are you seeing this on (Internet Explorer, Firefox, elsewhere?)
  • This occurs on SmartClient version 6.5.1, right?
  • The actual data being retrieved from the server may also have an impact on the behavior you’re seeing – you can get this by opening the Developer Console, and looking at the “RPC” tag. Check the “track RPCs” checkbox and then copy and paste the responses from the server so we can see the raw data you’re working with.

If we still can’t reproduce the problem with this additional info we may need to get in touch with you offline.

Hi,

I am back with few more doubts.

I have solved the javascript errors and thanks for the same.

Now When the listgrid data is filtered, I need to change the the values of the filtere editor. Ex:

data is some thing like this.

Country State city
India Karnataka Bangalore
India Karnataka Mysore
India Maharashtra Mumbai
India Maharashtra Pune
US CA Palo Alto
US CA Santa Clara
US IL Chicago

  1. Now when we filter with country as India, filter edior valueMap should be {Country:“India”},{State:“Karnataka”,“Maharastra”},{City:“Bangalore”,“Mysore”,“Mumbai”,“Pune”}

  2. If we further filter with State as “Karnataka”, filter editor valuemap should be {Country:“India”},{State"Karnataka",“Maharastra”},{City:“Bangalore”,“Mysore”}

  3. Any way we can set the values of the filter editor dynamically?

  4. When we say setShowFilterEditor(true) and setShowFilterEditor(false), the current filter criteria will be lost. (Internaly it destroys and recreates the RecordEditor)

Please help in solving this

Yes, calling filterData() on the ListGrid automatically populates the filterEditor with the criteria you specify.

Sorry,

I didnot understand,

I have defined filterData method inside listGrid,

So where to call the filterData().

isc.ListGrid.create({
.....

filterData: function(criteria,dsrequest,property)
	{

		isc.logWarn("criteria:"+isc.echo(criteria));
		
		if(criteria=="{}" || criteria=="")
		{
			this.setData(gridData);
			filteredData=gridData;
		}
else
		{
		var filt=filterGridData(criteria, gridData);
		filteredData=filt;
		this.setData(filt);
		}
	
	}
}

,

As you mentioned earlier in this thread, i am using setData function of the listGrid to populate the data fetched from datasource through call back.

Please help me in this as i am trying to fix this from last two months.

Thanks,
Ravi

As previously explained, the following code snippet we previously provided to you shows how to cause the filterEditor valueMap to update dynamically when new data is provided:

function updateGridData (data) {
    itemList.setData(data);

    // rebuild the filter editor to reset the set of options
    itemList.setShowFilterEditor(false);
    itemList.setShowFilterEditor(true);
}

Calling filterData() with criteria would normally populate the filterEditor’s values, but you seem to have overridden it without calling Super(). Overall, you seem to have started down a completely new path from what was previously recommend - are you doing your own, client-side filtering in your function filterGridData()?

We can’t recommend anything without seeing your complete new code so we can understand what approach you are now working on.

Hi filtering is working

Hi,

Thanks for the help.

It is working. when we say

itemList.setShowFilterEditor(false);
    itemList.setShowFilterEditor(true);

the filterEditor will be destroyed and reconstructed. It is costly operation. Also the current criteria will also lost (not selected in filter editor). For this i called setFilterEditorValues().

but , as my grid has more than 500 rows!, recreation of filter editor would be costly. if there is any other approach please suggest me.

filterGridData() filters the gridData stored based on critiaria

I dont want to connect to database when filtered. we have developed another widget to filter from server side. so i am using this function

may be some function be available

filterGridData: function (criteria, gridData)
    {
    	tempCriteria=criteria;
    	if(isc.getKeys(criteria).length==0)
    		return gridData;
    	var returnArray=new Array();
    	var count=0;
    	var keys=isc.getKeys(criteria);    	
    	for(var i=0; i<gridData.length;i++)
    	{
    		var toBeIncluded=true;
    		for(var j=0;j<keys.length;j++)
    		{
    			var keyValue=isc.getValueForKey(keys[j],criteria)+"";
    			var gridValue=isc.getValueForKey(keys[j],gridData[i])+"";
    			if(gridValue.startsWith(keyValue))
    			{
    				toBeIncluded=true;
    			}
    			else
    			{
    				toBeIncluded=false;
    				break;
    			}    			
    		}
    		if(toBeIncluded==true)
    		{
    			
    			returnArray[count]=gridData[i];
    			count=count+1;
    			//isc.logWarn("including : "+isc.echo( gridData[i].casenum));
    		}
    	}
    	return returnArray;
    }

It’s too bad you wrote your own filtering code, because there’s built-in support for this, even outside of a ListGrid. Search for applyFilter() - you may still want to use the built-in support, which is much, much faster than your filter code on the slowest browser (IE6).

Hiding and re-showing the filterEditor is somewhat expensive, however, you should check whether that’s really what’s slow. The time to show and hide the filterEditor isn’t strongly related to the number of rows, but your filter code would be.

Regardless, we can add an enhancement so that it is possible to make the filterEditorValueMaps more dynamic (either provide a setter, or call getFilterEditorValueMap more often). Contact Isomorphic here if interested in that.