:: Forum >>

refreshing a grid with updated value


I am populating a javascript array using a dataset in VB.NET. One of the columns of the dataset has a string in the form of a link <a href="#" onclick="myFunction">click</a>. This string is loaded into the array to just display 'click'. When this is clicked, a function is called which causes a database update. The page then reloads and text of the link changes. For example it said click, but know it could say clicked, hello, bye ... whatever, dependant on the value held in the dataset.

The problem I am comming across is reloading the javascript array with an updated dataset and redisplaying the grid with the updated value without a full page refresh.

This must be common behavour, so could anyone point me to an example or recommend how I would go about doing this? Very new to activewidgets so would appreciate it if explained in laymens terms?
Monday, September 22, 2008
are you looking for something like this?

Ryan Garabedian
Monday, September 22, 2008
Monday, September 22, 2008
Hi Thanks for the reply.

The problem I am having is the refreshing of the javascript array. I somehow need to refresh the VB dataset that the array uses, but can't think of a way how to?
Tuesday, September 23, 2008
If you need to get new data from where you get your original values from (a database) you need to do a new 'open'.



We use gridClear to remove the old content and gridFill to fill a grid named 'object.grid' with the (new) content from 'object.data'.
And everytime the tab containing this grid is clicked it will do a new open with a new gridFill.

'a' in this case contains instructions to fetch the data from our own database so I can't help you there ;)

If this is not what you meant please ellaborate ;)
Tuesday, September 23, 2008
Hi Wim,

Thanks for the reply. I think this is what I am looking for, however my Javascript is a bit limited. I currently get my data from a stored procedure using VB.NET, never made a connection using javascript. Will look into how this can be done.

Kind regards

Tuesday, September 23, 2008
also, is it safe to connect to a DB using javascript, would the user not be able to view the connection details if they viewed the source?
Tuesday, September 23, 2008
I am not familiar with how JS acts with passwords. Only with phpbb :D
At work we use a custom hash and some other stuff to hide the details and check on our end if the request is valid; so it's not inside our JS.

Regarding passwords. This
might be a good read :-)

But I am no expert in any way :)
Tuesday, September 23, 2008
cheers Wim, think I'll find a different way. Don't want to be responsible for getting our DB hacked :)
Tuesday, September 23, 2008
You really should use the ajax imlementation of active widgets. So amazingly simple. You request the data you want as so...
function AjaxRequest(strUrl)
var req = new AW.HTTP.Request;
//req.setAsync(true); // make synchronous request
req.response = function(text) {
FillGrid(StrResponse); // do something with response here
//have your asp script return the data as Javascript //variables. eg.
//ResponseColumns = ['id', 'name', 'phone', 'address', 'age'];
//ResponseData = [
//['1',' Bob Jones, '555-555-5555', '333 my blvd', '27']
//['2',' Bob Lemry, '555-555-5554', '331 my blvd', '28']
//['3',' Bob Jenkins, '555-555-5553', '332 my blvd', '29']
eval(StrResponse) ;
obj_columns = ResponseColumns;
obj_data = ResponseData;
obj.setRowCount(ArrLengthFormat(obj_data.length)); obj.setColumnCount(ArrLengthFormat(obj_columns.length-3));
obj.setSelectionProperty("multiple", true);
obj.setCellTemplate(new AW.Templates.Checkbox, 0);
obj.setCellValue(false, 0);
document.getElementById('awgrid').innerHTML = '';
document.getElementById('awgrid').innerHTML = obj;
<div id=awgrid name=awgrid > </div>
var obj_columns;
var obj_data;
var ResponseColumns;
var ResponseData;
var obj= new AW.UI.Grid;

This just hits the surface of what you can do. I've written client side search functions that are pretty speady along with ajax searches when the data is not found. The AW.xml class is so much better than the microsoft built in one and much easier to you. You can even load data to the grid directly from xml. If you use asp.net web services, this makes retrieving data a snap. However returning your data as Javascript variables is much more efficient. Have fun!

William Steele - CEO of WheresMyMedia
Tuesday, November 25, 2008
This site is really great
Saturday, November 29, 2008

This topic is archived.

Back to support forum

Forum search