Filter JSON from ASP.Net handler | Using Dojo 1.8 - ajax

Wanted to filter the results using Dojo 1.8 based upon the data received from server through a ASP.Net handler.
Handler Example - http://localhost/net/get8.ashx?longitude=-70.255325&latitude=43.661472&searchradius=200&searchunit=mi&locationtypes=3&numresults=20&Json=y
I could use (Store API) ItemFileReadStore but it's required specific format which we don't have and can't make the changes from the server end (JSON structure changes)
Able to successfully fetch the data through Dojo AJAX but looking for better way to filter the through some Dojo API.
One way around is, restructure the data again on client but it costs the performance and considering we developing for Mobile, doesn't look the right approach to take.
What all other options do we have in Dojo?
P.S. I just started learning Dojo Toolkit but having good experience in JavaScript.

The ItemFileReadStore has been replaced with the dojo/Store. You should be able to put the data into a dojo/store/Memory as is and query from that store.
http://dojotoolkit.org/reference-guide/1.8/dojo/store.html
http://dojotoolkit.org/reference-guide/1.8/dojo/store/Memory.html#dojo-store-memory

I already did use Object Store (Memory) to resolve the issue.

Related

Process huge no of records

I have developed a web application using spring mvc framework. My concern is I need to display huge no of records say around 100,000.
What would be the best approach to display those many no of records in UI.
Please use a front end framework like AngularJS get the data in JSON format and access the JSON data through your Angular code and use pagination. I have worked on a similar app and a fronted framework solved the problem.

100% Ajax Websites

I have been looking at Hulu's new website and I am very impressed from a developer's standpoint (as well as a designer's).
I have found that, unless you switch between http/https, you are served content entirely from json requests. That is a HUGE feat to have this level of ajax while maintaining browse back button support as well as allowing each url to be visited directly.
I want to create a website like this as a learning experience. Is there any type of framework out there that can give me this kind of support?
I was thinking I could...
leverage jQuery
use clientside MVVM frameworks like KnockoutJS?
use ASP.NET MVC content negotiation to serve html or json determined by an accept header.
using the same codebase.
use the same template for client side and server side rendering
provide ways to update pagetitle/meta tags/etc.
Ajax forms/widgets/etc would still be used, by I am thinking about page level ajax using json and client side templates.
What do you think? Any frameworks out there? Any patterns I could follow?
It is always best to first build a website without AJAX support, then add AJAX on top of that. Doing this means that:
users without javascript can already access your website
users can already visit any URL directly.
Adding AJAX support can be accomplished by various javascript libraries. So that you can render json content, you will want to look at javascript templating. You will want to use javascript templating even on your server side for when you add AJAX support (file extension .ejs). This will probably require some appropriate libraries to run javascript on the server.
When you add AJAX support, you will want to use the "History.js" library for browser back/forward/history support.
Make no mistake. This is a HUGE project (unless your website only has a few pages). So it is going to take a LONG time to add all the AJAX support to the best possible standard.
to answer your bullet point about using the same template server side as well as client side: check outdust. It was originally developed by akdubya, but has since been adopted and enhanced by linkedin. They use it to render templates on their mobile app client side. Personally I've used it on the server side and it works great.

Javascript file upload mechanism

I need for users to upload files (mostly images) without leaving the current webpage. What's the best tool, library or mechanism for doing this? I'm using the latest jQuery and Spring webmvc (with JSP), so if there's already a mechanism within them then that's ideal.
It would also be really great to have some kind of progress bar. Does that mean it requires coordination with the server to read the progress (where Spring would have to come into play)? Or is there a mechanism within JavaScript for this?
You should check out Plupload.
Plupload offers a cross-browser
JavaScript File uploading API that
handles multiple file uploads,
client-side progress meters, type
filtering and even client-side image
resizing and drag-and-drop from the
desktop. It achieves all of this by
providing backends for Flash,
Silverlight, Google Gears, HTML5 and
Browserplus and picking the most
capable available option.
Its really neat! Here's a link to some of their Demos...
http://www.plupload.com/example_jquery_ui.php
... and a screenshot of the jQuery UI queue widget (it has a progress bar!):
I hope this helps.
Hristo
I use uploadify pretty regularly: http://www.uploadify.com/
However it does use flash for the upload mechanism and as a result may create some issues if the user is authenticated.
You should use AJAX on the client side
http://www.webtoolkit.info/ajax-file-upload.html This tutorial covers all client side.
Om the server side
This tutorlal covers most of this issue:
http://www.ioncannon.net/programming/975/spring-3-file-upload-example/
Yopu can use jquery as well or any other JS framework.
But the mist important thing is the fact You need to remember that your tag on client side should have.
enctype='multipart/form-data'
property. it means that your request contains muultipart data.
Uploadify does that trick > http://www.uploadify.com/
All samples are php but you should be able to convert it to your platform.

jqGrid filtering

I want to implement filtering in my jqGrid in my Spring Framework MVC 3.0 project. Where can I find sample code or documentation telling how to use filtering in this?
I just posted an answer on the same question (probably from you) on http://www.trirand.com/blog/?page_id=393/help/jqgrid-filtering. To make other people easy to read the answer I post the same information here.
The answer on your question depends a little how you interpret the "filtering". If you want use some external controls (selects, checkboxes and so on on the same page where you have jqGrid) to filter your data I recommend you to read How to filter the jqGrid data NOT using the built in search/filter box.
If you want to implement data filtering inside of jqGrid you can choose between serching with respect of "search" and reset of serching results with respect of "refresh" buttons of the navigator (simple searching and advanced searching), the usage of toolbar searching (conside the usage of stringResult: true to be more conform with other form of searching) and custom searching.
If you decide to use advance searching you can just add string filter parameter to the (see Guidance on a better way to retain filtering options when using ASP.NET MVC 2) action which provide the grid data or add three string parameters searchField, searchString, searchOper if you want to use simple searching feature. In all cases you will have to add WHERE to the SELECT statments which will be constructed in your program based on the values of the new parameters.
Probably other people post you more URLs to the good full code examples which you could use.
UPATED: I don't use Spring Framework myself, so I could not help you with any Spring MVC 3.0 examples. Some general solution is more common. For example in ASP.NET MVC solutions I prefer don't fill the data in the grid directly using MVC. Instead of that I provide a JSON web service (implemented as a part of ASP.NET MVC solutions or as WCFservice which are the part of the same web site) which URL I place in the jqGrid parameter. So you should just invest in the writing on business logic in form of JSON/XML web service which provide the data. The most jqGrid specific code you can write in JavaScript. So you can share the experience of other people in the usage of jqGrid and have a clear separation of HTML code from the business logic. Moreover JSON/XML web services can be better tested for example with respect of unit tests.

Ajax architecture in Django application

I am trying to find the optimal architecture for an ajax-heavy Django application I'm currently building. I'd like to keep a consistent way of doing forms, validation, fetching data, JSON message format but find it exceedingly hard to find a solution that can be used consistently.
Can someone point me in the right direction or share their view on best practice?
I make everything as normal views which display normally in the browser. That includes all the replies to AJAX requests (sub pages).
When I want to make bits of the site more dynamic I then use jQuery to do the AJAX, or in this case AJAH and just load the contents of one of the divs in the sub page into the requesting page.
This technique works really well - it is very easy to debug the sub pages as they are just normal pages, and jQuery makes your life very easy using these as part of an AJA[XH]ed page.
For all the answers to this, I can't believe no one's mentioned django-piston yet. It's mainly promoted for use in building REST APIs, but it can output JSON (which jQuery, among others, can consume) and works just like views in that you can do anything with a request, making it a great option for implementing AJAX interactions (or AJAJ [JSON], AJAH, etc whatever). It also supports form validation.
I can't think of any standard way to insert ajax into a Django application, but you can have a look to this tutorial.
You will also find more details on django's page about Ajax
Two weeks ago I made a write up how I implement sub-templates to use them in "normal" and "ajax" request (for Django it is the same). Maybe it is helpful for you.
+1 to Nick for pages displaying normally in the browser. That seems to be the best starting point.
The problem with the simplest AJAX approaches, such as Nick and vikingosegundo propose, is that you'll have to rely on the innerHTML property in your Javascript. This is the only way to dump the new HTML sent in the JSON. Some would consider this a Bad Thing.
Unfortunately I'm not aware of a standard way to replicate the display of forms using Javascript that matches the Django rendering. My approach (that I'm still working on) is to subclass the Django Form class so it outputs bits of Javascript along with the HTML from as_p() etc. These then replicate the form my manipulating the DOM.
From experience I know that managing an application where you generate the HTML on the server side and just "insert" it into your pages, becomes a nightmare. It is also impossible to test using the Django test framework. If you're using Selenium or a similar tool, it's ok, but you need to wait for the ajax request to go return so you need tons of sleeps in your test script, which may slow down your test suite.
If the purpose of using the Ajax technique is to create a good user interface, I would recommend going all in, like the GMail interface, and doing everything in the browser with JavaScript. I have written several apps like this using nothing but jQuery, state machines for managing UI state and JSON with ReST on the backend. Django, IMHO, is a perfect match for the backend in this case. There are even third party software for generating a ReST-interface to your models, which I've never used myself, but as far as I know they are great at the simple things, but you of course still need to do your own business logic.
With this approach, you do run into the problem of duplicating code in the JS and in your backend, such as form handling, validation, etc. I have been thinking about solving this with generating structured information about the forms and validation logic which I can use in JS. This could be compiled at deploy-time and be loaded as any other JS file.
Also, avoid XML. The browsers are slow at parsing it, it is a pain to generate and a pain to work with in the browser. Use JSON.
Im currently testing:
jQuery & backbone.js client-side
django-piston (intermediate layer)
Will write later my findings on my blog http://blog.sserrano.com

Resources