This topic is locked
[SOLVED]

  Pass selected rows in list page to external page.

6/29/2011 2:33:27 PM
PHPRunner General questions
J
JCRamos author

I need to include in a page list a link to an external site to process those rows selected with the checkbox used to delete or edit records.

How I can access the selected rows to build the parameter to send to the external page?
Thanks.

C
cgphp 6/29/2011

JCRamos,
you have to insert a custom button. The "server" option of the button gives you access to the $keys parameter that contains the information about all records that are selected on the list page.

J
JCRamos author 6/30/2011

Thank you.

Although I prefer another solution that was not a button, because at least in version 5.3.7113 if you delete a button and its code, in the project file (. PHPR) had still not cleared.

For example: define a field for each row with a checkbox and associated code so that each time you chek or uncheck it, add or delete the key of the row in an environment variable. The contents of this variable could be passed as a parameter to the external page.
I'll try the button for this version.
Thanks again.

C
cgphp 6/30/2011

Yes, a solution like yours is possible but some custom javascript code and AJAX calls are necessary.

J
JCRamos author 7/3/2011

Sorry. In Spanish.
Solucionado. Solo con JavaScript y PHP. Me he servido del ejemplo que hay en la ayuda de PHPRunner:

  • Si no lo está ya, añadir la pagina de imprimir la lista.
  • Incluir en el editor HTML de la pagina de lista junto al enlace de imprimir el codigo:



<INPUT id=imprimir_seleccion1 class=button value="[ IMPRIMIR INFORMES SELECCIONADOS ]" type=button name=seleccion1>


  • Si no nos interesa, podemos borrar el enlace a imprimir las lineas seleccionadas que ha generado PHPRunner y nos ha servido de referencia.
  • Para asociar con el boton la accion de abrir una nueva pagina, en el evento JavaScript OnLoad de la pagina de la lista, incluir el codigo:



var submitUrl = "imprimir_lote_pdf.php";

if (typeof id == "undefined")

{ id = this.id;

}

pageObj = this;

$("#imprimir_seleccion"+this.id).unbind("click").bind("click", function(e){

var selBoxes = $('input[@type=checkbox][@checked][@id^=check'+id+'_]');

if(selBoxes.length == 0 || !confirm('¿Quire imprimir los informes de las pruebas seleccionadas?')){

return false;

}

var form = new Runner.form.BasicForm({

standardSubmit: true,

submitUrl: submitUrl,

method: 'POST',

id: pageObj.id,

baseParams: {"a": 'lote'},

addElems: cloneElements(selBoxes)

});

return openwin(form);

form.destructor();

});

//define preWin function

var prevWin = null;

function openwin(oForm)

{ if (prevWin && !prevWin.closed)

prevWin.close();

prevWin = window.open('', 'prevWin', 'left=200,top=200,width=750,height=620,status=0');

oForm.target = 'prevWin';

oForm.action = 'imprimir_lote_pdf.php';

oForm.submit();

if (prevWin && !prevWin.closed)

prevWin.focus();

return true;

}


  • En la pagina externa llamada (imprimir_lote_pdf.php), recogemos la lista de lineas seleccionadas y ya podemos procesarla, por ejemplo para crear una cadena con los elementos del array:



$p_lista_pruebas="";

for ($i=0;$i<count($_REQUEST["selection"]);$i++ )

$p_lista_pruebas.=$_REQUEST["selection"][$i].",";

$p_lista_pruebas = substr($p_lista_pruebas,0,-1);