Query Issue

QuestionsQuery Issue
Alfonso Cabrera asked 4 years ago

Hi Abu!

I have master-detail grid, inside the detail grid I need to get a value from the database, I put the following code inside the code that generate the detail grid.

/**********Detail Grid*************/
$grid = new jqgrid();

$id = intval($_GET["rowid"]);
$idListas_Precios = Carga_Id(intval($_GET["idClientes"]));

$opt = array();
$opt["sortname"] = 'idProduccion_Detalle'; // by default sort grid by this field
$opt["sortorder"] = "asc"; // ASC or DESC

The problem is that when I call the Carga_Id function it seems to block the input search box in the dropdown with the select2 feature.

Below is the code for the dropdown.

$col = array();
$col["title"] = "Vidrio";
$col["name"] = "idVidrio";
//$col["dbname"] = "productos.idProductos"; // this is required as we need to search in name field, not id
$col["align"] = "left";
$col["width"] = 200;
$col["search"] = true;
$col["editable"] = true;
$col["formatter"] = "select";
$col["edittype"] = "select"; // render as select
# fetch data from database, with alias k for key, v for value
$str = $g->get_dropdown_values("select idProductos as k, descripcion as v from productos");
$col["editoptions"] = array(
"value"=>"null:;".$str,
"onchange" => array(
"sql"=>"SELECT precio FROM precios WHERE idListas_Precios = '".$idListas_Precios."'",
"search_on"=>"idProductos",
"callback" => "fill_vidrio" )
);
$col["editoptions"]["dataInit"] = "function(){ setTimeout(function(){ link_select2('idVidrio'); },200); }";
$cols[] = $col;

I need to get the price that corresponds to the id_client and the id_list that the client has.

Can you help me out? Everything works as expected but the problem is I can't search the product in the dropdown.

2 Answers
Abu Ghufran answered 4 years ago

Please email me ([email protected]) complete grid code and db script to regenerate scenario.
I'll be updating back after review.

Abu Ghufran answered 4 years ago

I regenerated all your ccode, and it work after adding
onSelect: function(){ jQuery(this).trigger('change'); }

in link_select2 function. e.g.

function link_select2(id)
{
$('select[name='+id+'].editable, select[id='+id+']').select2({width:'95%', dropdownCssClass: 'ui-widget ui-jqdialog', onSelect: function(){ jQuery(this).trigger('change'); } });
$(document).unbind('keypress').unbind('keydown');
}

Your Answer

17 + 1 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?