Client Side Binding of Dynamic Drop Downs

Similar documents
DIPLOMA IN WEBDEVELOPMENT

Abstract. Description

Tableau Server Trusted Authentication

Example. Represent this as XML

07/04/2014 NOBIL API. Version 3.0. Skåland Webservice Side 1 / 16

Merkle Hash Trees for Distributed Audit Logs

Qlik REST Connector Installation and User Guide

Progressive Enhancement With GQuery and GWT. Ray Cromwell

Web application Architecture

Tableau Server Trusted Authentication

Citrix StoreFront. Customizing the Receiver for Web User Interface Citrix. All rights reserved.

WIRIS quizzes web services Getting started with PHP and Java

CMSC434 TUTORIAL #3 HTML CSS JavaScript Jquery Ajax + Google AppEngine Mobile WebApp HTML5

Developing ASP.NET MVC 4 Web Applications

Course Information Course Number: IWT 1229 Course Name: Web Development and Design Foundation

Sitecore Dashboard User Guide

Introduction to Ingeniux Forms Builder. 90 minute Course CMSFB-V6 P

Lab 5 Introduction to Java Scripts

MVC FRAMEWORK MOCK TEST MVC FRAMEWORK MOCK TEST II

MASTERTAG DEVELOPER GUIDE

Performance Testing for Ajax Applications

Developing ASP.NET MVC 4 Web Applications MOC 20486

Visualizing a Neo4j Graph Database with KeyLines

InPost UK Limited GeoWidget Integration Guide Version 1.1

Developing ASP.NET MVC 4 Web Applications Course 20486A; 5 Days, Instructor-led

Learning More About Load Testing

High-Performance Oracle: Proven Methods for Achieving Optimum Performance and Availability

Application Design and Development

Distance Examination using Ajax to Reduce Web Server Load and Student s Data Transfer

Big Data Analytics in LinkedIn. Danielle Aring & William Merritt

Performance Testing Process A Whitepaper

NASSI-SCHNEIDERMAN DIAGRAM IN HTML BASED ON AML

HP Business Process Monitor

4.2 Understand Microsoft ASP.NET Web Application Development

StreamServe Persuasion SP4 Service Broker

Yandex.Widgets Quick start

Developing Web Views for VMware vcenter Orchestrator

Visualizing an OrientDB Graph Database with KeyLines

FormAPI, AJAX and Node.js

Term Paper. P r o f. D r. E d u a r d H e i n d l. H o c h s c h u l e F u r t w a n g e n U n i v e r s i t y. P r e s e n t e d T o :

English. Asema.com Portlets Programmers' Manual

PHP Tutorial From beginner to master

IBM Watson Ecosystem. Getting Started Guide

EPiServer and XForms - The Next Generation of Web Forms

Oracle Database: SQL and PL/SQL Fundamentals

Further web design: HTML forms

FF/EDM Intro Industry Goals/ Purpose Related GISB Standards (Common Codes, IETF) Definitions d 4 d 13 Principles p 6 p 13 p 14 Standards s 16 s 25

Programming Fundamentals of Web Applications Course 10958A; 5 Days

Evaluation of Nagios for Real-time Cloud Virtual Machine Monitoring

Implementing Mobile Thin client Architecture For Enterprise Application

Using Steelhead Appliances and Stingray Aptimizer to Accelerate Microsoft SharePoint WHITE PAPER

Glyma Deployment Instructions

The purpose of jquery is to make it much easier to use JavaScript on your website.

Art of Code Front-end Web Development Training Program

Learning Web App Development

Performance Tuning for the JDBC TM API

Web Development using PHP (WD_PHP) Duration 1.5 months

metaengine DataConnect For SharePoint 2007 Configuration Guide

Terms and Definitions for CMS Administrators, Architects, and Developers

WEB DEVELOPMENT COURSE (PHP/ MYSQL)

QML and JavaScript for Native App Development

MOVING THE SENIOR DEVELOPMENT CLASS FROM WEB DEVELOPMENT TO LIFE CYCLE DEVELOPMENT A CASE FOR VISUAL STUDIO 2005

Drupal CMS for marketing sites

Best Practices for Rich Media Ads in Asynchronous Ad Environments

This matches a date in the MM/DD/YYYY format in the years The date must include leading zeros.

Oracle Database: SQL and PL/SQL Fundamentals NEW

maximizing IT productivity

SnapLogic Salesforce Snap Reference

CRM Developer Form

Michigan State University. Team Meijer. Tablet-Based Point-of-Sale System. Project Plan. Fall 2011

Adding Panoramas to Google Maps Using Ajax

Programming Against Hybrid Databases with Java Handling SQL and NoSQL. Brian Hughes IBM

Intro to Web Programming. using PHP, HTTP, CSS, and Javascript Layton Smith CSE 4000

Microsoft Extending Microsoft Dynamics CRM 2011

Up and Running with LabVIEW Web Services

Security Research Advisory IBM inotes 9 Active Content Filtering Bypass

Advanced Java Client API

INF5750/9750 Introduction INF5750/ Lecture 1 (Part I)

Power Tools for Pivotal Tracker

Mobile Performance: for excellent User Experience

Expanded contents. Section 1. Chapter 2. The essence off ASP.NET web programming. An introduction to ASP.NET web programming

An Oracle White Paper June RESTful Web Services for the Oracle Database Cloud - Multitenant Edition

This course provides students with the knowledge and skills to develop ASP.NET MVC 4 web applications.

Oracle Database Security and Audit

MyOra 3.0. User Guide. SQL Tool for Oracle. Jayam Systems, LLC

Modern Web Development From Angle Brackets to Web Sockets

A Brief Introduction to MySQL

Transcription:

International Journal of Scientific and Research Publications, Volume 5, Issue 9, September 2015 1 Client Side Binding of Dynamic Drop Downs Tanuj Joshi R&D Department, Syscom Corporation Limited Abstract- This paper talks about How to bind dynamic content in a webpage? What are the challenges to fetch dynamic content from the server? What can be the other approach to bind dynamic content? Index Terms- Client Side Binding of Dynamic Drop Downs, jquery, How to write jquery Code to bind Dynamic Content Performance!!! This is what everyone expects from others and himself too in every aspect of life. Whether you are playing, studying or doing any activity performance always matters. When it comes to websites, performance is the major factor which decides the efficiency of that website. In this paper, I demonstrate a technique which increases the page performance of any website. A section in performance enhancement has been implemented using jquery which demonstrates that how the page performance can be increased by reducing the response time for the page. I I. INTRODUCTION t is very often that we have to bind dynamic dropdowns in our website or application. For implementing the same, various approaches are used. There are two basic approaches for doing this: 1: By Re-Loading Complete Page from the Server (Full Postback). 2: By Re-Loading Only Required Element of a Page (Partial Postback using AJAX). I would like to introduce a different approach for binding the dynamic dropdowns in any web application. By using this approach, the load time of dependent dropdowns (or it may be any other control as per your need) is reduced and as a result the total response time of the application also decreases. II. PURPOSE The purpose for introducing this technique is mainly to reduce the response time of web pages that contains the dynamic dropdowns. Also, it reduces the round trips to the server for fetching the data of dynamic dropdowns. Usually in a web application, when the dynamic dropdown data needs to be populated, it is fetched from the server, this takes a lot of time thus response time of a web page increases. This problem is solved using my approach and ultimately the performance of a page is increased. III. CLARIFY THE PROBLEM For binding the dynamic content in page either people uses full postback approach or partial postback by using AJAX. Let s talk about the first one, in full postback when the dynamic content is required, the whole page gets loaded again. Whereas in partial postback, instead of loading the whole page, only the dropdown content is fetched from the server. Although in partial postback response time is much decreased but in both the cases, a call has to be made to the server for just fetching the values of the dropdowns or it may be some other small dynamic value. This reduces the performance of the page as round trips to the server are made each time the data is required for dynamic dropdowns. IV. HOW THE SITUATION OCCURRED Suppose there is an application that is hosted in a different region and it is being accessed at various other regions. In such cases, it takes a long time in binding dynamic dropdowns for the pages which results in a bad user experience. Reason being, the latency is very high because of the distance between the client and the server. Moving further, suppose we have three dropdowns named as Region, Country and State. Data is dynamically binding to these dropdowns. Now, if we choose a region from the region dropdown, the data dynamically gets fetched for the country dropdown and same for the State dropdown. This whole process takes a lot of time as round trips are made to the server. Even if I am using partial postback approach then it takes 4-5 seconds to load the country dropdown. This is a major problem faced and I don t think using postback approach is suitable for such a small problem.

International Journal of Scientific and Research Publications, Volume 5, Issue 9, September 2015 2 Figure 1: Clients are waiting for the Dynamic Content V. SOLUTION Here I have come up with a solution by using the jquery. This solution loads all the data from the server to the local machine of the client at the time of page loading. As all the content is present in the local machine and server round trip needs not to be done for fetching the dynamic content this increases the response time of a page. Also, the approach is language independent (means on can use Java, C# or any other language at server side) making it flexible enough to be implemented using any language. Through this, let s see how I am achieving the same: PREREQUISITES: As I have already mentioned that we have 3 dependent dropdowns in my page Region, Country and State. In which Region dropdown is a parent dropdown, Country dropdown is a parent-child dropdown and State is a child dropdown. So the value of child and parentchild dropdowns must contain some logical data that will link it with its parent dropdown. Before using this approach we have to ensure that at client end the data of the drop down should be bind in following format: <select id="region"> <option>--select--</option> <option value="1">africa</option> <option value="2">asia</option> <option value="3">europe</option> <option value="4">oceania</option> <option value="5">north America</option> <option value="6">south America</option> </select> Figure 2: HTML of Region Dropdown List Rendered at Client Machine

International Journal of Scientific and Research Publications, Volume 5, Issue 9, September 2015 3 <select id="country"> <option>--select--</option> <option value="5,2">afghanistan</option> <option value="6,2">bangladesh</option> <option value="7,2">bhutan</option> <option value="8,2">china</option> <option value="9,2">egypt</option> <option value="10,2">georgia</option> <option value="11,2">india</option>. </select> Figure 3: HTML of Country Dropdown List Rendered at Client Machine Purpose to show this html code is to notice the highlighted value field. Here value attribute contains comma separated string in which first part indicates the ID of the Country and the second part indicates ID of the Region. <select id="state"> </select> <option>--select--</option> <option value="5,11">andhra Pradesh</option> <option value="6,11">arunachal Pradesh</option> <option value="7,11">assam</option> <option value="8,11">bihar</option> <option value="9,11">chhattisgarh</option> <option value="10,11">goa</option> <option value="11,11">gujarat</option> <option value="12,11">haryana</option> Figure 4: HTML of State Dropdown List Rendered at Client Machine In the above code first part of value field indicates the ID of the state and the other part indicates ID of the corresponding country. PROCEDURE As I have mentioned above that Region drop down is parent drop down and Country drop down is a child drop down of Region as its value depends on selected Region. A child drop down must contain all its values with corresponding Parent value. Now I will explain by quoting an example so that it will be clearer. What I am doing, loading the complete data of all dynamic dropdown when the page loaded first time and assigning the whole data of Country drop down into an array at client side by using jquery. This array will contain Country Name, Country ID and Region ID. When a Region is selected then I am clearing all data from Country dropdown and re-assigning the data to Country dropdown from the array based on selected Region ID. Now you can see data to Country dropdown is populated without any postback.

International Journal of Scientific and Research Publications, Volume 5, Issue 9, September 2015 4 Figure 5: Dropdown at Client Machine Following are the steps to implement the client side binding of dynamic dropdowns by using jquery: NOTE: Here I am displaying the code to bind Country on the basis of selected Region as my purpose is to give an idea only. STEP 1: Declare an array to hold all the items of the Country dropdown. var arrcountry[]; STEP 2: Iterate over Country DropDown and insert items on array arrcountry[]. $("#Country option").each(function (index) { var val = $(this).val(); var CombinedID = val.split(","); var item = {} item["regionid"] = CombinedID[1]; item["countryid"] = CombinedID[0]; item["countryname"] = $(this).text(); }); arrcountry.push(item); STEP 3: Declare a variable myjsonstring. var myjsonstring; STEP 4: Declare a variable myjsonstring.

International Journal of Scientific and Research Publications, Volume 5, Issue 9, September 2015 5 var myjsonstring; STEP 5: Convert arrcountry[] into JSON text and store it in a string. myjsonstring = JSON.stringify(arrCountry); STEP 6: Store JSON string into a hidden field or in hidden text area. $("#data").val(myjsonstring); STEP 7: Create a function to Handle the Change Event of Primary Dropdown. a. Declare a variable RegionID that will contain the selected RegionID from dropdown. var selectedregionid = $(this).val(); b. Parse the data into JSON contained in hidden field and assign this data into a new variable CountryData. var CountryData = jquery.parsejson($("#data").val()); c. Remove all the options from Country Dropdown. $("#Country").find("option").remove(); d. Iterate over CountryData and assign data to country dropdown. jquery.each(countrydata, function (i, jarray) { if (selectedregionid == jarray["regionid"]) { $('#Country').append($('<option>', { value: jarray["countryid"], text: jarray["countryname"] })); }); }

International Journal of Scientific and Research Publications, Volume 5, Issue 9, September 2015 6 VI. CONCLUSION Although and is widely used but in my opinion there are some scenarios where latency is very high, it is not preferable. For such scenarios I prefer the jquery approach for binding the dynamic content at client side. This work was supported by Syscom Corporation Ltd. ACKNOWLEDGEMENT http://www.w3schools.com/jquery/ https://jquery.com/ REFERENCES AUTHORS First Author Tanuj Joshi, M.C.A, Software Engineer, tanuj.joshi@live.com