:: Forum >>

refreshing a grid with updated value

Hi,

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?
Russ
Monday, September 22, 2008
are you looking for something like this?

obj.refresh();
Ryan Garabedian
Monday, September 22, 2008
http://www.activewidgets.com/javascript.forum.22155.2/grid-refresh-problem.html
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?
Russ
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'.

object.open.request=function(){
<..>
ajaxRequest(a,'omzet.open.result');
};

object.open.result=function(requestcount,result,a){
object.data=eval(unescape(getAttribute('object',result)));
gridClear(object.grid);
gridFill(object.grid,object.data);
};

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 ;)
Wim
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

Russell
Russ
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?
Russ
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
http://www.developer.com/lang/jscript/article.php/639061
might be a good read :-)

But I am no expert in any way :)
Wim
Tuesday, September 23, 2008
cheers Wim, think I'll find a different way. Don't want to be responsible for getting our DB hacked :)
Russ
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.setURL(strUrl);
//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']
//];
FillGrid(StrResponse)
{
eval(StrResponse) ;
obj_columns = ResponseColumns;
obj_data = ResponseData;
obj.clear();
obj.setRowCount(ArrLengthFormat(obj_data.length)); obj.setColumnCount(ArrLengthFormat(obj_columns.length-3));
obj.setCellText(obj_data);
obj.setHeaderText(obj_columns);
obj.setSelectionProperty("multiple", true);
obj.setCellTemplate(new AW.Templates.Checkbox, 0);
obj.setCellValue(false, 0);
document.getElementById('awgrid').innerHTML = '';
document.getElementById('awgrid').innerHTML = obj;
}
<html>
<body>
<div id=awgrid name=awgrid > </div>
<script>
var obj_columns;
var obj_data;
var ResponseColumns;
var ResponseData;
var obj= new AW.UI.Grid;
AjaxRequest('Ajaxdata.asp?groupid=5');
</body>
</html>

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!

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

This topic is archived.


Back to support forum

Forum search