Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Listgrid - filter by time field

    Hi, I have a DateTime field which its type set to 'Time'. I want to allow the user to filter it by the time part only.
    Something like: morning (6:00-18:00), evening(18:00-00:00), night(00:00-06:00).

    How can I do that? I tried Criteria\Advanced Criteria and none of them seem to have a builtin capability for what I need.

    #2
    If you provide a logical time in criteria for a “between” or similar filter on a “time” field, only the time portion is used.

    Comment


      #3
      I tried that, and it didn't work:

      myGrid.filterData({
      _constructor:"AdvancedCriteria",
      operator:"and",
      criteria:[
      { fieldName:"eventTime", operator:"betweenInclusive", start:isc.DateUtil.createLogicalTime(19,0,0,0), end:isc.DateUtil.createLogicalTime(20,0,0,0)}
      ]
      });

      It returns all the data, no filtering occurs.
      What am I doing wrong here?

      Comment


        #4
        We can’t tell, because we don’t have the DataSource or the data and we can’t currently tell whether this is client- or server-side filtering we’re talking about - but if you can provide the necessary information we can help.

        Comment


          #5
          I used your test case here:
          https://www.smartclient.com/smartcli.../?id=localData

          and changed the 'countryData' data source to be like this:
          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",
          testTime: new Date(2020,1,28,14,00)
          },
          {
          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",
          testTime: new Date(2020,1,28,19,00)
          },
          {
          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",
          testTime: new Date(2020,1,27,14,00)
          },
          {
          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",
          testTime: new Date(2020,1,28,18,00)
          },
          {
          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",
          testTime: new Date(2020,1,26,14,00)
          },
          {
          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",
          testTime: new Date(2020,1,28,11,00)
          },
          {
          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",
          testTime: new Date(2020,1,20,14,00)
          },
          {
          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",
          testTime: new Date(2020,1,28,20,00)
          },
          {
          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",
          testTime: new Date(2020,1,28,15,00)
          },
          {
          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",
          testTime: new Date(2020,1,30,14,00)
          },
          {
          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",
          testTime: new Date(2020,1,28,12,00)
          },
          {
          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",
          testTime: new Date(2020,1,28,14,30)
          },
          {
          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",
          testTime: new Date(2020,1,27,14,00)
          },
          {
          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",
          testTime: new Date(2020,1,28,18,00)
          },
          {
          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",
          testTime: new Date(2020,1,28,15,00)
          }

          ]


          I added this new field to the listGrid:
          isc.ListGrid.create({
          ID: "countryList",
          width:500, height:224, alternateRecordStyles:true,
          fields:[
          {name:"countryCode", title:"Code"},
          {name:"countryName", title:"Country"},
          {name:"capital", title:"Capital"},
          {name:"testTime", title:"Test", type:"time"}
          ],
          data: countryData
          })


          And now when I try to filter as you suggested it doesn't work (all the data is still displayed):

          countryList.filterData({fieldName:"testTime",operator:"between",start:isc.Time.createLogicalTime(14,0), end: isc.Time.createLogicalTime(15,0)})
          Last edited by kshamir; 28 Jan 2020, 04:02.

          Comment


            #6
            Since there is no DataSource declaration of the field as type:”time” this would not be expected to work.

            Comment


              #7
              I see now!
              I tried that now (defining it as 'time" type in the data source) with another show-case on your website, and it worked as expected.
              Thanks for your help.

              Comment

              Working...
              X