Listgrid filter not working

Hi ,

I want filter functionality on my listgrid,its giving me error, will be helpful if you can help me on this, below is my code

isc.ListGrid.create({
    ID: "countryList",
    width:500, height:224, alternateRecordStyles:true, showAllRecords:true,
    data: countryData,
    fields:[
        {name:"countryCode", title:"Flag", width:50, type:"image", imageURLPrefix:"flags/16/", imageURLSuffix:".png"},
        {name:"countryName", title:"Country"},
        {name:"population", title:"Population", formatCellValue:"isc.Format.toUSString(value)"},
        {name:"area", title:"Area (km²)", formatCellValue:"isc.Format.toUSString(value)"}
    ],
    // initial sort on Population, high-to-low
    sortFieldNum: 2,
    sortDirection: "descending",autoFetchData: true,
    showFilterEditor: true

})

countryData = [

{
    continent:"North America",
    countryName:"United States",
    countryCode:"US",
    area:9631420,
    population:298444215,
    gdp:12360.0,
    independence:new Date(1776,6,4),
    government:"federal republic",
    government_desc:2,
    capital:"Washington, DC",
    member_g8:true,
    article:"http://en.wikipedia.org/wiki/United_states"
},
{
    continent:"Asia",
    countryName:"China",
    countryCode:"CH",
    area:9596960,
    population:1313973713,
    gdp:8859.0,
    government:"Communist state",
    government_desc:0,
    capital:"Beijing",
    member_g8:false,
    article:"http://en.wikipedia.org/wiki/China"
},
{
    continent:"Asia",
    countryName:"Japan",
    countryCode:"JA",
    area:377835,
    population:127463611,
    gdp:4018.0,
    government:"constitutional monarchy with parliamentary government",
    government_desc:1,
    capital:"Tokyo",
    member_g8:true,
    article:"http://en.wikipedia.org/wiki/Japan"
},
{
    continent:"Asia",
    countryName:"India",
    countryCode:"IN",
    area:3287590,
    population:1095351995,
    gdp:3611.0,
    independence:new Date(1947,7,15),
    government:"federal republic",
    government_desc:2,
    capital:"New Delhi",
    member_g8:false,
    article:"http://en.wikipedia.org/wiki/India"
},
{
    continent:"Europe",
    countryName:"Germany",
    countryCode:"GM",
    area:357021,
    population:82422299,
    gdp:2504.0,
    independence:new Date(1871,0,18),
    government:"federal republic",
    government_desc:2,
    capital:"Berlin",
    member_g8:true,
    article:"http://en.wikipedia.org/wiki/Germany"
},
{
    continent:"Europe",
    countryName:"United Kingdom",
    countryCode:"UK",
    area:244820,
    population:60609153,
    gdp:1830.0,
    independence:new Date(1801,0,1), 
    government:"constitutional monarchy",
    government_desc:1,
    capital:"London",
    member_g8:true,
    article:"http://en.wikipedia.org/wiki/United_kingdom"
},
{
    continent:"Europe",
    countryName:"France",
    countryCode:"FR",
    area:547030,
    population:60876136,
    gdp:1816.0,
    government:"republic",
    government_desc:5,
    capital:"Paris",
    member_g8:true,
    article:"http://en.wikipedia.org/wiki/France"
},
{
    continent:"Europe",
    countryName:"Italy",
    countryCode:"IT",
    area:301230,
    population:58133509,
    gdp:1698.0,
    independence:new Date(1861,2,17),
    government:"republic",
    government_desc:5,
    capital:"Rome",
    member_g8:true,
    article:"http://en.wikipedia.org/wiki/Italy"
},
{
    continent:"Asia",
    countryName:"Russia",
    countryCode:"RS",
    area:17075200,
    population:142893540,
    gdp:1589.0,
    independence:new Date(1991,7,24),
    government:"federation",
    government_desc:3,
    capital:"Moscow",
    member_g8:true,
    article:"http://en.wikipedia.org/wiki/Russia"
},
{
    continent:"South America",
    countryName:"Brazil",
    countryCode:"BR",
    area:8511965,
    population:188078227,
    gdp:1556.0,
    independence:new Date(1822,8,7),
    government:"federative republic",
    government_desc:3,
    capital:"Brasilia",
    member_g8:false,
    article:"http://en.wikipedia.org/wiki/Brazil"
},
{
    continent:"North America",
    countryName:"Canada",
    countryCode:"CA",
    area:9984670,
    population:33098932,
    gdp:1114.0,
    independence:new Date(1867,6,1),
    government:"constitutional monarchy with parliamentary democracy and federation",
    government_desc:1,
    capital:"Ottawa",
    member_g8:true,
    article:"http://en.wikipedia.org/wiki/Canada"
},
{
    continent:"North America",
    countryName:"Mexico",
    countryCode:"MX",
    area:1972550,
    population:107449525,
    gdp:1067.0,
    independence:new Date(1810,8,16),
    government:"federal republic",
    government_desc:2,
    capital:"Mexico (Distrito Federal)",
    member_g8:false,
    article:"http://en.wikipedia.org/wiki/Mexico"
},
{
    continent:"Europe",
    countryName:"Spain",
    countryCode:"SP",
    area:504782,
    population:40397842,
    gdp:1029.0,
    independence:new Date(1492,0,1),
    government:"parliamentary monarchy",
    government_desc:4,
    capital:"Madrid",
    member_g8:false,
    article:"http://en.wikipedia.org/wiki/Spain"
},
{
    continent:"Asia",
    countryName:"South Korea",
    countryCode:"KS",
    area:98480,
    population:48846823,
    gdp:965.3,
    independence:new Date(1945,7,15),
    government:"republic",
    government_desc:5,
    capital:"Seoul",
    member_g8:false,
    article:"http://en.wikipedia.org/wiki/South_korea"
},
{
    continent:"Asia",
    countryName:"Indonesia",
    countryCode:"ID",
    area:1919440,
    population:245452739,
    gdp:865.6,
    independence:new Date(1945,7,17),
    government:"republic",
    government_desc:5,
    capital:"Jakarta",
    member_g8:false,
    article:"http://en.wikipedia.org/wiki/Indonesia"
}

]

Listgrid filter not working

Hi,

i get an error, too.

it is only possible to activate the filter for the first field in the field-array.
if i activate the filter for any other field, i get the following error:

TypeError: _6 is null, ISC_Grids.js, Row:918

thx for help

after some experiments, i found the following:
if i set no width for the fields, everything works fine.
if i set th width for field 1 bigger than 80, then i get th error.

@kens: you have no DataSource. Filtering requires a DataSource.

@phk: that’s bizarre and isn’t happening to anyone else :slight_smile: Can you create a standalone test case?

Here is my testcase:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
  <title>hOS</title>
  <script type="text/javascript">/* <![CDATA[ */
    var isomorphicDir="/SmartClient/smartclientRuntime/isomorphic/";
  /* ]]> */</script>
  <script type="text/javascript" src="/SmartClient/smartclientRuntime/isomorphic/system/modules/ISC_Core.js"></script>
  <script type="text/javascript" src="/SmartClient/smartclientRuntime/isomorphic/system/modules/ISC_Foundation.js"></script>
  <script type="text/javascript" src="/SmartClient/smartclientRuntime/isomorphic/system/modules/ISC_Containers.js"></script>
  <script type="text/javascript" src="/SmartClient/smartclientRuntime/isomorphic/system/modules/ISC_Grids.js"></script>
  <script type="text/javascript" src="/SmartClient/smartclientRuntime/isomorphic/system/modules/ISC_Forms.js"></script>
  <script type="text/javascript" src="/SmartClient/smartclientRuntime/isomorphic/system/modules/ISC_DataBinding.js"></script>
  <script type="text/javascript" src="/SmartClient/smartclientRuntime/isomorphic/skins/Standard/load_skin.js"></script>
</head>

<body>
</body>

<script type="text/javascript">/* <![CDATA[ */
  hUsersDS=[
    {id:"1", username:"user1", email:"user1@domain.com", vorname:"John 1", nachname:"Doe 1"},
    {id:"2", username:"user2", email:"user2@domain.com", vorname:"John 2", nachname:"Doe 2"},
    {id:"3", username:"user3", email:"user3@domain.com", vorname:"John 3", nachname:"Doe 3"},
    {id:"4", username:"user4", email:"user4@domain.com", vorname:"John 4", nachname:"Doe 4"}
  ];

  isc.Layout.create({
    ID:"hOSScreen",
    width:"100%",
    height:"100%",
    orientation:"vertical",
    members:[
      isc.Canvas.create({
        ID:"MyDesktop",
        height:"100%",
        backgroundColor:"#D5EDF9"
      }),
      isc.HLayout.create({
        height:19,
        members:[
          isc.MenuButton.create({
            title:"Start",
            showMenuBelow:false,
            showMenuButtonImage:false,
            showRollOver:false,
            align:"center",
            height:'100%',
            menu:isc.Menu.create({
              autoDraw:false,
              data:[
                {title:"testcase",click:"MyDesktop.addChild(isc.hUsers.create({top:70,left:150,taskbar:tbTaskbar}));"},
              ]
            })
          }),
          isc.Toolbar.create({
            ID:"tbTaskbar",
            height:'100%',
            backgroundColor:"#B8CBDC",
            layoutLeftMargin:10,
            windows:[],
            addWindow:function(pWindow){
              lvButton=isc.Button.create({
                window:pWindow,
                title:pWindow.title,
                taskbar:this,
                actionType:"radio",
                radioGroup:"rgTaskbar",
                autoFit:true,
                click: function(){
                  if((!this.window.isVisible())||(this.taskbar.windows.indexOf(this.window)>0)){
                    this.window.show();
                  }else{
                    this.window.hide();
                  }
                }
              });
              pWindow.tbButton=lvButton;
              this.addMember(lvButton);
              this.windows.unshift(pWindow);
            }
          })
        ]
      })
    ]
  });

  isc.defineClass("clsWindow",Window).addProperties({
    taskbar:tbTaskbar,
    tbButton:null,
    showMaximizeButton:true,
    keepInParentRect:true,
    initWidget: function(){
      this.Super("initWidget", arguments);
      this.taskbar.addWindow(this);
    },
    bringToFront: function(){
      this.Super("bringToFront",arguments);
      lvPos=this.taskbar.windows.indexOf(this);
      if(lvPos>-1){
        this.taskbar.windows.removeAt(lvPos);
        this.taskbar.windows.unshift(this);
        this.tbButton.select();
      }
    },
    setTitle:function(newTitle){
      this.Super("setTitle",arguments);
      this.tbButton.setTitle(newTitle);
    },
    minimize:function(){
      this.hide();
      lvPos=this.taskbar.windows.indexOf(this);
      if(lvPos>-1){
        this.taskbar.windows.removeAt(lvPos);
        this.taskbar.windows.push(this);
      }
      var lvFoundVisible=false;
      for(var lvI=0;lvI<this.taskbar.windows.length;lvI++){
        if(this.taskbar.windows[lvI].isVisible()){
          this.taskbar.windows[lvI].bringToFront();
          lvFoundVisible=true;
          break;
        }
      }
      if(!lvFoundVisible)this.tbButton.deselect();
    },
    closeClick:function(){
      this.taskbar.windows.removeAt(this.taskbar.windows.indexOf(this));
      this.tbButton.destroy();
      this.destroy();
    }
  });

  isc.defineClass("hUsers",clsWindow).addProperties({
    title:"hUsers",
    width:800,
    height:600,
    canDragReposition:true,
    canDragResize:true,
    initWidget:function(){
      this.Super("initWidget",arguments);
      this.addItem(isc.VLayout.create({
        members:[
          isc.Canvas.create({
            contents:"testinfo"
          }),
          isc.ListGrid.create({
            data:hUsersDS,
            autoFetchData:true,
            sortFieldNum:2,
            showFilterEditor:true,
            fields:[
              {name:"vorname", title:"Vorname", width:130, canGroupBy:false},
              {name:"nachname", title:"Nachname", width:150, canGroupBy:false},
              {name:"username", title:"Username", width:150, canGroupBy:false},
              {name:"email", title:"eMail", width:300, canGroupBy:false},
            ]
          }),
          isc.Canvas.create({
            contents:"testinfo"
          })
        ]
      }));
    }
  });
  MyDesktop.addChild(isc.hUsers.create({top:70,left:150}));
/* ]]> */</script>

</html>

@phk filtering requires a DataSource. If you don’t need to load data from a server, use a clientOnly:true DataSource.

yes, of course i know, that a datasource is necessary.
But the problem is not the filtering.
The problem happens before i have the chance to filter.
If i use a Datasource, it is the same problem.
The component isn’t drawn correctly.
There just appears a grey rectangle.
If i delete the width-settings for the ListGrid-Fields everything is drawn correctly.

You need a DataSource to do filtering. If that leads to a strange gray square, look into that instead, most likely, it’s a JS error.

maybe my english is not good enough to tell you the problem.
so i try it again:
if i use a datasource instead, it is the same problem.
My real application uses datasources.
The source i posted here is just the standalone test case, that you asked for.

Here are 3 scenarios:

  1. “showFilterEditor” is set to “false”
    the grid is displayed correctly

  2. “showFilterEditor” is set to “true” but the fields width is not defined
    the grid is displayed correctly

{name:"vorname", title:"Vorname", canGroupBy:false},
{name:"nachname", title:"Nachname", canGroupBy:false},
{name:"username", title:"Username", canGroupBy:false},
{name:"email", title:"eMail", canGroupBy:false}
  1. “showFilterEditor” is set to “true” and the fields width is defined
    then there is just displayed a grey rectangle.
{name:"vorname", title:"Vorname", width:130, canGroupBy:false},
{name:"nachname", title:"Nachname", width:150, canGroupBy:false},
{name:"username", title:"Username", width:150, canGroupBy:false},
{name:"email", title:"eMail", width:300, canGroupBy:false}

please try these 3 scenarios to see what i’m trying to explain.
just open the file with your browser.
no further useraction is necessary.

by luck i found a solution for my problem.

if “showFilterEditor” is set to false, everything works fine.

but if “showFilterEditor” is set to true, it is extremly necessary to set “width” of every parent element.
Even if there would be no difference in the displayed result compared to not setting it.

Anyway:
I think that this is a bug in the system.
Because: Why does it work correctly when “showFilterEditor” is not set or set to false and fails when “showFilterEditor” is set to true?

But this is just my humble opinion.

Still something no one else is reporting :slight_smile: BTW, get rid of the XHTML docType, that’s not current for SmartClient and could create problems.

Hi Isomorphic,

I too confirm this error and could resolve the error as suggested by PHK. Could not understand the cause of problem.

Page Details:
I have implemented my custom paginated search result grid, where user can traverse pages based on next and prev labels. Also, this grid has filter support and contains as many columns that user has to use horizontal scroller to traverse all.

Error Scenario:
When I do a group by field and collapse all the records. When clicking next link to render next page of reproduces the same error “_6 is null” as described by PHK in previous post.

I have used the same temporary fixed suggested by PHK with this everything works fine.

It’s not a temporary fix. Filtering requires a DataSource and enabling filtering without a DataSource will crash (after logging a warning). Not sure what the difficulty is in understanding this..

I mean following is the fix, you went wrong in understanding:

BY PHK: (refer prev posts)

but if "showFilterEditor" is set to true, it is extremly necessary to set "width" of every parent element.
Even if there would be no difference in the displayed result compared to not setting it.

Try putting together a standalone testcase. Your description sounds like a deeply customized grid; there’s no indication yet that this is anything other than the same usage error affecting two people.