Saturday, June 1, 2024
 Popular · Latest · Hot · Upcoming
75
rated 0 times [  82] [ 7]  / answers: 1 / hits: 65262  / 13 Years ago, tue, february 28, 2012, 12:00:00

I have a JSON file which contains data like the following:


{"posts": [ 
{ "title":"1", "url":"n1.png" },
{ "title":"2", "url":"n2.png" },
{ "title":"3", "url":"n3.png" },
{ "title":"4", "url":"n4.png" },
{ "title":"5", "url":"n5.png" },
{ "title":"6", "url":"n6.png" },
{ "title":"7", "url":"n7.png" },
{ "title":"8", "url":"n8.png" },
{ "title":"9", "url":"n9.png" },
{ "title":"10", "url":"n10.png" }
]}

I need to filter title by range with two text boxes: from and to.


More From » json

 Answers
46

I use Linq JS on my current project and it works really well for filtering data.



http://jslinq.codeplex.com/



var posts = [ 
{ title:1, url:n1.png },
{ title:2, url:n2.png },
{ title:3, url:n3.png },
{ title:4, url:n4.png },
{ title:5, url:n5.png },
{ title:6, url:n6.png },
{ title:7, url:n7.png },
{ title:8, url:n8.png },
{ title:9, url:n9.png },
{ title:10, url:n10.png }
];

var filteredPost = JSLINQ(posts)
.Where(function(item){ return item.title >= textBox1Value && item.title <= textBox2Value; });

[#87163] Monday, February 27, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
peytont

Total Points: 215
Total Questions: 110
Total Answers: 111

Location: Armenia
Member since Sat, Dec 31, 2022
1 Year ago
;