EasyUI Forum
April 29, 2024, 03:16:59 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: issue with multiple property of combogrid  (Read 11481 times)
catpaw
Jr. Member
**
Posts: 85


View Profile Email
« on: October 14, 2013, 04:57:46 PM »

I'm using the combogrid with multiple property in a form.
I have 2 actions: Add and Edit, so when I do the Add, the combogrid it looks ok but in the php side only got the last item I selected.
To correct this issue I added like a "new" parameter in the onSubmit function for the submit method.
Like this:
param.almacenes = $('#almacenes').combogrid('getValues');
and it works, I've got every item I selected.
But when I want do a edit a register, I select it and I get a message error:

The object does not accept the property or method join.

In this case the combogird should load the values store in the data base in that field and I get a blank combogrid.

Here's my full code:

the html:

the combogrid:
Code:
<input id="almacenes" name="almacenes" class="easyui-combogrid" style="width:240px" 
                            data-options=" 
                            multiple: true,
                            panelWidth:240,
                            panelHeight:280,
                            mode:'remote',
                            url: 'folder/get_almacenes.php',
                            idField:'id', //like 100, 300 o A23
                            textField:'id',
                            fitColumns:false,
                            columns:[[
                                    {field:'ck',checkbox:true},
                                    {field:'id',title:'Clave',width:50},
                                    {field:'name',title:'Nombre',width:155}
                                ]]"
                        />

easyui function to save the form data:
Code:
function save(){
$('#form').form('submit',{
url: url,
onSubmit: function(param){
param.almacenes = $('#almacenes').combogrid('getValues'); //this instruction had to add to get all the items I select......otherwise I only get the last one select
var isValid = $(this).form('validate');
return isValid;
},
success: function(result){
var result = eval('('+result+')');
if (result.success){
$('#dlg').dialog('close');
$('#dg').datagrid('reload');
$.messager.alert('Aviso','Operación éxitosa','info');
} else{
$.messager.alert('Error',result.msg,'error');
}
}
});
}

and the php code:
Code:
//get the variable, 
$almacenes = $_POST['almacenes'];
//the content should be like: 100,300,A23 (for example)
//and after do the insert to db

the field that stores this variable is varchar (100)

I'm using the 1.3.2. version

thank you so much

*sorry for my bad english
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: October 15, 2013, 05:51:10 PM »

Try this.
Code:
<input id="almacenes" name="almacenes[]" class="easyui-combogrid" ...>
Code:
//get the variable, 
$almacenes = join(',', $_POST['almacenes']);
//now the content is: 100,300,A23 (for example)
Logged
catpaw
Jr. Member
**
Posts: 85


View Profile Email
« Reply #2 on: October 30, 2013, 01:02:48 PM »

hi thank you for your time

first change the name tag, like you said:

name="almacenes[]"

 Cheesy I seems reasonable

but, then if I change this:

$almacenes = $_POST['almacenes'];

to this:

$almacenes = join(',', $_POST['almacenes']);

almacenes field is not saved in the database

mi query insert is:

$sql = "INSERT INTO table (field1, field2, field3, almacenes) values ('$value1', '$value2', '$value3', '$almacenes')";

and in the edition still do not checked the selected rows
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!