3

W2UI GRID

I want to have grid search like in datatables .net

It uses 'AND' condition for search text separated by space.

My requirement is not to use that advance search which is already there next to search box because it is specific column based.

"records": [
{ "recid": 1, "fname": "John", "lname": "Doe", "email": "[email protected]", "sdate": "4/3/2012" },
{ "recid": 2, "fname": "John", "lname": "Motzart", "email": "[email protected]", "sdate": "4/3/2012" },
{ "recid": 3, "fname": "John", "lname": "Franson", "email": "[email protected]", "sdate": "4/3/2012" },
{ "recid": 4, "fname": "Susan", "lname": "Franson", "email": "[email protected]", "sdate": "4/3/2012" },
{ "recid": 5, "fname": "Kelly", "lname": "Franson", "email": "[email protected]", "sdate": "4/3/2012" },
{ "recid": 6, "fname": "Francis", "lname": "Franson", "email": "[email protected]", "sdate": "4/3/2012" },
{ "recid": 7, "fname": "Mark", "lname": "Welldo", "email": "[email protected]", "sdate": "4/3/2012" },
{ "recid": 8, "fname": "Thomas", "lname": "Bahh", "email": "[email protected]", "sdate": "4/3/2012" },
{ "recid": 9, "fname": "Sergei", "lname": "Rachmaninov", "email": "[email protected]", "sdate": "4/3/2012" }
]

Now in w2ui grid search box I am searching "John" then it should display 1,2,3 records

Then I am searching "john fran" then it should only display 3rd record.

how to achieve this?

I have tried splitting string of search box by space and made changes in w2ui.js but It always searches for the last word in search string,

please help , thanks :) :)

Anoop B.K
  • 1,484
  • 2
  • 17
  • 31

1 Answers1

0

The easiest way to do this is by adding a new value of "fullname" to your records.

records: [
{ "recid": 1, "fname": "John", "lname": "Doe", "email": "[email protected]", "sdate": "4/3/2012", "fullname": "John Doe" },
{ "recid": 2, "fname": "John", "lname": "Motzart", "email": "[email protected]", "sdate": "4/3/2012", "fullname": "John Motzart" },
{ "recid": 3, "fname": "John", "lname": "Franson", "email": "[email protected]", "sdate": "4/3/2012", "fullname": "John Franson" },
{ "recid": 4, "fname": "Susan", "lname": "Franson", "email": "[email protected]", "sdate": "4/3/2012", "fullname": "Susan Franson" },
{ "recid": 5, "fname": "Kelly", "lname": "Franson", "email": "[email protected]", "sdate": "4/3/2012", "fullname": "Kelly Franson" },
{ "recid": 6, "fname": "Francis", "lname": "Franson", "email": "[email protected]", "sdate": "4/3/2012", "fullname": "Francis Franson" },
{ "recid": 7, "fname": "Mark", "lname": "Welldo", "email": "[email protected]", "sdate": "4/3/2012", "fullname": "Mark Welldo" },
{ "recid": 8, "fname": "Thomas", "lname": "Bahh", "email": "[email protected]", "sdate": "4/3/2012", "fullname": "Thomas Bahh" },
{ "recid": 9, "fname": "Sergei", "lname": "Rachmaninov", "email": "[email protected]", "sdate": "4/3/2012", "fullname": "Sergei Rachmaninov" }

and then you can add this properties to your grid to search data based on the "fullname" value.

searches: [
            { field: 'fullname', caption: 'Name', operator: 'begins', type: 'text' }
        ]