filter in neotable - Forum

Forum Navigation
You need to log in to create posts and topics.

filter in neotable

How can filter a neotable according range of date(in between two dates)?

Uploaded files:
  • You need to login to have access to uploads.

@asmat

The current version of the neoTable plugin (for VisualNEOWeb) only supports searches for column values that are equal to those specified in the neoTableFilter command.

I took a peek at the underlying library (i.e. the Bootstrap Table plugin) and noticed that it does have facilities for "custom search criteria".

Until this facility is developed/extended to neoTable, if you are interested, I have a suggestion for a work around ...

a) have an additional column (e.g. HideThisRow) in your data ... keep it hidden (from the user) in the neoTable View

b) in response to a search query by the user, loop through all rows to determine matching rows ... and set the value for HideThisRow to "Yes" or "No"

c) then do ...

CreateEmptyObject [filterObject]
SetVar [filterObject('HideThisRow')] "No"
neoTableFilter "ViewsContainer" [filterObject]

As an aside ...

a) when doing date comparisons, it is best to work with date values ... there are Javascript methods to convert string values to numbers (I believe the numbers are "elapsed milliseconds since Jan/01 1900 or something similar) ... that way, all you have to do is compare two numbers.

b) make sure that the format of your date strings are consistent i.e. months and days should always have 2 digits (e.g. 05 or 11) ...

1985-03-27 (not 1985-3-27)
2012-11-04 (not 2012-11-4)

luishp and asmat have reacted to this post.
luishpasmat

Thanks @Gaev

According your guidance I did like this:

I set for filter button this code:

BEGINJS
  $App.myFilteredObject= $App.mydata.filter(neosubroutine.check);
ENDJS

neoTableLoadData "BasicTableContainer" [myFilteredObject]

And for check subroutine with item  parameter I have set the below code:

var mydate=item.date;
const startRange=$App.startPoint;
const endRange=$App.endPoint;


var itemArray=mydate.split("-");
var startArray=startRange.split("-");
var endArray=endRange.split("-");

 var a=Number(startArray[0]+startArray[1]+startArray[2]);
 var b=Number(itemArray[0]+itemArray[1]+itemArray[2]);
 var c=Number(endArray[0]+endArray[1]+endArray[2]);

if( b>=a && b<=c){
  return item;
}

and it works fine. @Gave if you have any more recommendation please tell me...

Uploaded files:
  • You need to login to have access to uploads.

@asmat

and it works fine. if you have any more recommendation please tell me...

a) To quote someone whose name I do not remember ... If it ain't (is not) broken, don't fix it ... so, I am glad you found a method that worked.

b) having said that ...

- you chose to build a subset of json data that met the criteria; hopefully, you have a separate original copy of the full data ... in case you need to show another subset of matching data

- f.y.i. take a look at date related methods within Javascript  (especially Date.valueOf() ) on the w3schools website ... converting date strings to numbers makes it a lot easier to do compares.

 

Take care.

asmat has reacted to this post.
asmat