question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Search number between range

See original GitHub issue

Hello guys,

I’m trying to implement a advanced search field in a column where it returns the results between two given inputs:

<input type="number" placeholder="From" #inputField1 style="width:150px">
<input type="number" placeholder="To" #inputField2 style="width:150px">
<button class="btn-primary" type="button" (click)="amountRange(inputField1.value, inputField2.value)">GO</button>
 amountRange(beginValue: string, endValue: string){
    if(!beginValue && !endValue){
      this.source = new LocalDataSource(this.data);
    }else{
      this.source.addFilter([
        {
          field: 'amount',
          search: [beginValue, endValue],
          filter:{
            
          }
        }
      ], false);
    }
  }

Any ideias how to implement filter function? Thanks 😃

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:9

github_iconTop GitHub Comments

5reactions
DidierBoutincommented, Apr 11, 2019

search can be a tab; so you can initialize parameters in one shot :

  this.source.setFilter([
    {
      field: 'amount',
      search: ['2010-01-01' ,  '2015-01-01']
      filter: (value: string, serachValue: string) =>{
      return (new Date(value) >= new Date(searchValue[0]) && (new Date(value) <= new Date(searchValue[1])) )
      }
  }])
5reactions
shilancommented, Oct 17, 2017

I actually found a better solution inspired by your code that guarantees we get to both filters and that is filtering on return value of a filter here it is

`  dateRange(beginDate: string, endDate: string) {
    if (!(!beginDate && !endDate)) {
        this.source.setFilter([
          {
            field: 'batchDateAsString',
            search: endDate,
            filter: (value: string, endValue: string) => {
              return new Date(value) <= new Date(endValue);
            }
          }
        ], true).setFilter([
          {
            field: 'batchDateAsString',
            search: beginDate,
            filter: (value: string, beginValue: string) => {
              return new Date(value) >= new Date(beginValue);
            }
          }
        ]);
    } else {
      this.source = new LocalDataSource(this.data);
    }
  }`
Read more comments on GitHub >

github_iconTop Results From Across the Web

Lookup value between two numbers - Excel formula - Exceljet
To lookup values between two values and return a corresponding result, you can use the LOOKUP function and a sorted table. In the...
Read more >
Lookup Value in a Range and Return in Excel (5 Easy Ways)
I'll show you 5 easy ways to lookup value in a range and return in Excel. Let's say, we have a dataset, where...
Read more >
How to return a value if lookup value is in a range
In this article, I will demonstrate four different formulas that allow you to lookup a value that is to be found in a...
Read more >
Search an element in given N ranges - GeeksforGeeks
Given an array of N sorted ranges and a number K. The task is to find the index of the range in which...
Read more >
How To Find The Range | What Is Range In Math - DK Find Out!
The range is the difference between the smallest and highest numbers in a list or set. To find the range, first put all...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found