3.2.0

Row content to array on button click

I'm trying to retreive the data from a row upon clicking a button, but I'm not sure how to achieve this. Could some please offer advice. Here is a portion of my grid code

displayRules.php -------------------->
...
<style>
.active-controls-grid {font:menu;}
.active-row-cell {border-right: 1px dotted #99ccff}
.active-column-0 {width:0px; text-align:center;}
.active-column-1 {width:120px}
.active-column-2 {width:220px}
.active-column-3 {width:100px}
.active-column-4 {width:100px}
.active-column-5 {width:110px}
.active-image-activeLight {background: url("../images/ActiveRuleDark2.jpg")}
.active-image-deactiveLight {background: url("../images/InactiveRuleDark2.jpg")}
</style>
<?php

// add grid to the page
echo activewidgets_grid($name, $data);
?>
.....
//Onclick of image, place selected/highlighted row content into an array
<a href="toggleRule.php"><img src="../images/ToggleUp.gif" ></a>

activeWidget.php ---------------------------------->
...
$row_count = @mysql_num_rows($data);
$column_count = @mysql_num_fields($data);

//Set column names
$columnsHeaders = "var ".$name."_columnsHeaders = [\n";
$columnsHeaders .= "\"".Status."\",";
$columnsHeaders .= "\"".Name."\",";
$columnsHeaders .= "\"".Description."\",";
$columnsHeaders .= "\"".Created."\",";
$columnsHeaders .= "\"".Table."\",";
$columnsHeaders .= "\"".Chain."\",";
$columnsHeaders .= "\n];\n";

//Create array of row header images and row data
$myImages = "var ".$name."_myImages = [\n";
$rows = "var ".$name."_data = [\n";
while ($result = @mysql_fetch_array($data)) {
$rows .= "[";
for ($i=0; $i < $column_count; $i++) {
$rows .= "\"".activewidgets_html($result[$i])."\", ";
//Status image
if($result[0]=='1')
$myImages .= "\"".activeLight."\", ";
else if($result[0]=='0')
$myImages .= "\"".inactiveLight."\", ";
}
$rows .= "],\n";
}
$rows .= "];\n";
$myImages .= "\n];\n";

$myBlank = "var ".$name."_myBlank = [\n";
$myBlank .= "\"".''."\",";
$myBlank .= "\n];\n";

$html = "<"."script".">\n";
$html .= $columns;
$html .= $rows;
$html .= $columnsHeaders;
$html .= $myImages;
$html .= $myBlank;
$html .= "try {\n";
$html .= " var $name = new Active.Controls.Grid;\n";
$html .= " $name.setRowCount($row_count);\n";
$html .= " $name.setColumnCount($column_count);\n";
$html .= " $name.setColumnText(function(i){return ".$name."_columnsHeaders[i]});\n";
$html .= " $name.setRowProperty(\"text\", function(i,j){return ".$name."_myBlank[0]});\n";
$html .= " $name.setRowProperty(\"image\", function(i,j){return ".$name."_myImages[i]});\n";
$html .= " $name.setDataText(function(i,j){return ".$name."_data[i][j]});\n";
$html .= " document.write($name);\n";
$html .= "}\n";
$html .= "catch (error){\n";
$html .= " document.write(error.description);\n";
$html .= "}\n";
$html .= "</"."script".">\n";

return $html;
...
---------->
Thank you
Avnish
February 25,
Avnish,

Take a look at the Drag & Drop demo at:
http://friendsofaw.com/nuke/modules.php?name=Demos

In this demo I move a grid row to the drop location by grabbing the entire row. Look at "function dragstop(column, row)". I get the row directly from the JS array using:
var startrowcontents = CellText[startrow];

With my data it gets something like:
["7","Description 7"]

which is is an array representing the entire row.

Hope that will get you going in the right direction.

Rob Francis
February 25,
Thanks for the prompt repsonse. I understand what your'e getting at, but do you have an example of where you call the dragstart/dragstop functions so I can see how you pass the column and row variables from the line selected in the grid?
Thanks
Avnish
February 26,
Hi Avnish,

The example is at:
http://friendsofaw.com/nuke/modules.php?name=Demos

Click on the 'Drag & Drop' row example and view the source. Search for dragstop.

The main code you will need is:
var startrowcontents = CellText[startrow]; 
CellText.splice((stoprow*1)+1,0,startrowcontents); //INSERT DRAG ROW BELOW DROP ROW 
CellText.splice(startrow,1); // DELETE DRAG ROW


Note, startrow and stoprow are row numbers.
Rob Francis
February 26,
Is the function "obj.getSelectedRows([0]); " supported in v1.0?

Is there another function that selects the row in v1.0?
Regards
Avnish
March 1,

This topic is archived.

See also:


Back to support forum