Ajax DataGrid Support Product Page

Solved

Set session variable from row click

Reported 05 Oct 2011 05:32:04
2
have this problem
05 Oct 2011 05:32:04 Andrew Brown posted:
I want to set a session variable from when a user clicks a row. How do I do this?

Official Solution

Replied 23 Jan 2012 12:44:50
Hello,

We've already relesed a new version of Ajax Data Grid that includes a fix. Please download it from our website.

Replies

Replied 06 Oct 2011 09:37:41
06 Oct 2011 09:37:41 Miroslav Zografski replied:
Hello Andrew,

Clicking on the row can trigger a javascript function and passing the value you like to be set in session variable. From there you have two options:
  • submitting a hidden form which to pass the value to a server side script which to set this value to a session variable. This will refresh the page.
  • making an ajax call with passing that value to a server side script a page that will set this Session variable. This will not refresh the page.


Replied 07 Oct 2011 01:34:04
07 Oct 2011 01:34:04 Andrew Brown replied:
Thanks, I am trying to figure out how to call the javascript but not having much success. I can't find any examples to follow.

I did find a javascript that might work, but not sure how to call it. I know if you go into row behaviors, select call Javascript, then click add customer code. But what do I put in there?

Here is the javascript which calls a php that sets the session.

function set_georef_id(str)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP";
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
if(str=="hide"
{
document.getElementById("left_side".style.display='none';
document.getElementById("left_side_show".style.display='';
}
if(str=="show"
{
document.getElementById("left_side".style.display='';
document.getElementById("left_side_show".style.display='none';
}
}
}
xmlhttp.open("GET","set_georef_id.php?georef_id="+str,true);
xmlhttp.send();
}



Replied 07 Oct 2011 10:26:54
07 Oct 2011 10:26:54 Miroslav Zografski replied:
Hello Andrew,

In the custom code you need to place following:
set_georef_id({name_of_the_column_that_holds_the_value_you_like_to_set})
Replied 07 Oct 2011 14:21:24
07 Oct 2011 14:21:24 Andrew Brown replied:
Ok, that is what I thought but I was getting an error, must be a datatype issue with the value retrieved from the datagrid and the javascript requiring a string.
Replied 12 Oct 2011 01:31:20
12 Oct 2011 01:31:20 Andrew Brown replied:
Ok still not getting anywhere here. I get the error

set_georef_id({0});
TypeError: (void 0) is undefined


Seems to me that the {0} is not being translated to a value for the javascript.

I took everything out of the javascript and just put

window.open("GET","set_georef_id.php?georef_id="+str,true);

And still get the same error.

I have also changed this to just going to a URL and it seems like the problem is with not converting the value of georef_id. What am I doing wrong?

Here is the code:

<script type="text/javascript" language="javascript">
<!--
$(function(){$('#dmx_grid2').flexigrid({
url: "ajax_servers/dmx_grid2.php",
title: "Geolocality",
showSearchOnLoad: true,
floatingSearch: true,
sortname: "georef_id",
dataType: "json",
rpOptions: [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],
onrowclick: "MM_goToURL('parent','set_georef_id.php?georef_id={georef_id}');",
colModel: [{
display: "georef_id",
name: "georef_id",
width: 100,
sortable: true,
align: "left",
hide: false
},
{
display: "point id",
name: "point_id",
width: 100,
sortable: true,
align: "left",
hide: false
},
{
display: "east",
name: "east",
width: 100,
sortable: true,
align: "left",
hide: false
},
{
display: "north",
name: "north",
width: 100,
sortable: true,
align: "left",
hide: false
},
{
display: "zone",
name: "zone",
width: 100,
sortable: true,
align: "left",
hide: false
},
{
display: "datum",
name: "datum",
width: 100,
sortable: true,
align: "left",
hide: false
},
{
display: "latdecimal",
name: "latdecimal",
width: 100,
sortable: true,
align: "left",
hide: false
},
{
display: "longdecimal",
name: "longdecimal",
width: 100,
sortable: true,
align: "left",
hide: false
},
{
display: "posacccode",
name: "posacccode",
width: 100,
sortable: true,
align: "left",
hide: false
},
{
display: "field altitude",
name: "field_altitude",
width: 100,
sortable: true,
align: "left",
hide: false
},
{
display: "locality notes",
name: "locality_notes",
width: 100,
sortable: true,
align: "left",
hide: false
}],
searchitems: [{
display: "georef_id",
name: "georef_id",
isdefault: true
},
{
display: "point id",
name: "point_id"
},
{
display: "east",
name: "east"
},
{
display: "north",
name: "north"
},
{
display: "zone",
name: "zone"
},
{
display: "datum",
name: "datum"
},
{
display: "latdecimal",
name: "latdecimal"
},
{
display: "longdecimal",
name: "longdecimal"
},
{
display: "posacccode",
name: "posacccode"
},
{
display: "field altitude",
name: "field_altitude"
}]
});});
//-->
</script>


Edited by - Andrew Brown on 12 Oct 2011  07:04:36
Replied 12 Oct 2011 09:51:45
12 Oct 2011 09:51:45 Miroslav Zografski replied:
Hello Andrew,

Can you pass in a link to the page in question?
Replied 12 Oct 2011 12:51:01
12 Oct 2011 12:51:01 Andrew Brown replied:
Ok I had to recreate via an example as the site I am working on is behind a firewall. So this is just a simple grab of data into the datagrid then a row behavior that should take you to the set_session.php

Still gives the same error.

photomontage.com.au/dmzgrid.php
Replied 14 Oct 2011 01:32:32
14 Oct 2011 01:32:32 Andrew Brown replied:
Still stumped with this, any ideas?
Replied 17 Oct 2011 04:48:25
17 Oct 2011 04:48:25 Andrew Brown replied:
Hi, this seems to have dropped off the radar. It's a really basic task I am trying to perform and it isn't working and I paid for this.
Replied 17 Oct 2011 10:11:46
17 Oct 2011 10:11:46 Miroslav Zografski replied:
Hello Andrew,

Instead of setting the behavior on row click try using on cell click behavior for test.
Replied 19 Oct 2011 12:22:34
19 Oct 2011 12:22:34 Andrew Brown replied:
Ok that worked, but why won't it work on the row?
Replied 20 Oct 2011 09:58:23
20 Oct 2011 09:58:23 Miroslav Zografski replied:
Hello Andrew,

Seems a last minute bug in the packaging.
We are working to get the issue resolved.
Replied 31 Oct 2011 07:21:26
31 Oct 2011 07:21:26 Andrew Brown replied:
Has this been fixed yet? And also, if I want to pass a URL 2 querystring values, ie georef_id and point_id, how would I do this via the cell behavior
Replied 01 Nov 2011 01:11:47
01 Nov 2011 01:11:47 Andrew Brown replied:
Hi I really need resolution to this as I have a deadline by Friday and I have committed to using this product.
Replied 03 Nov 2011 14:58:01
03 Nov 2011 14:58:01 Andrew Brown replied:
So is there a fix yet?
Replied 04 Nov 2011 12:26:13
04 Nov 2011 12:26:13 Teodor Kuduschiev replied:
Hello Andrew,

The issue will be fixed in the upcoming update.
Replied 14 Nov 2011 06:55:17
14 Nov 2011 06:55:17 Andrew Brown replied:
Thanks, also noted that the select cell works on Firefox 3.6 only. ie it's not working on Chrome or IE or later versions of Firefox.
Replied 21 Nov 2011 12:36:54
21 Nov 2011 12:36:54 Joe Horton replied:
When is the next update?

Edited by - Joe Horton on 21 Nov 2011  12:47:33
Replied 23 Jan 2012 12:44:50
23 Jan 2012 12:44:50 Teodor Kuduschiev replied:
Hello,

We've already relesed a new version of Ajax Data Grid that includes a fix. Please download it from our website.

Reply to this topic