Nitobi
Customer Login
Services
Products
About
Blogs
Contact
Home -> Product Knowledgebase Order Online | Free Trial Downloads

Nitobi Product Knowledgebase

How to Pass Arguments to the GetHandler from a ListBox


Grid 3.2 and newer offers a special mechanism for adding and maintaining gethandler parameters. Since grid adds its own parameters to the gethandler, its necessary to keep track of custom parameters, and to test the custom parameters.

In this example, we will be using a listbox to display some values that we want to filter.  For example, if we want to get everything in a certain category, we can then get only those items from the database of that category and only display those items in the grid.

Here is an example of the listbox:

<form name="myForm" method="GET" action="">
 <select name="myList" >
 <option value="Adhesive">Adhesive</option>
 <option value="Additive">Additive</option>
 <option value="Body">Body</option>
 <option value="Ceramic">Ceramic</option>
 <option value="Electronics">Electronics</option>
 </select>

We can then change our initialization so that it looks like this:

function init()
{
 var DBGrid = nitobi.loadComponent('DataboundGrid'); 
 var selectObj = document.forms.myForm.myList;
 var index = document.forms.myForm.myList.selectedIndex
 selectObj.onchange = function(){getData(document.forms.myForm.myList.options[index].value)}; 
}

In this example, we're getting the value of the listbox, and loading it into the getData function by setting the onchange event in JavaScript.

Now, we need to define getData.  getData will be our function that will actually maintain the attribute:

function getData(query_param)
{
 var myDataGrid = nitobi.getGrid('DataboundGrid');
 myDataGrid.getDataSource().setGetHandlerParameter('myparam', query_param);
 myDataGrid.databind();
}

We pass in the query parameter query_param and add it to the query string as myparam.  This is the name of  the parameter that the get_handler will be getting.  The important thing is that the parameter here has to match what is being passed to the back-end GetHandler script, otherwise this will not do anything.

dataBind then calls GET and retrieves data using the new properties. Later, you can use the setGetHandlerParameter again to edit the properties.

View Printable Version

Comments:


Name:

Type the text you see above:

Comments:


Knowledgebase

To be notified of new articles when they're available, subscribe to our RSS feed.

Support Resources

Take advantage of our knowledgebase of product tutorials and tips, and our support forums!

Search Site


Sign up for our Newsletter:

Get industry articles and Nitobi company news in your inbox every couple of months — here's a sample!

Email:




Site RSS Feed  | All contents are (c) Copyright 2006, Nitobi Software Inc. All rights Reserved