EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: tokick4 on April 19, 2013, 06:13:39 PM



Title: problem not display of value
Post by: tokick4 on April 19, 2013, 06:13:39 PM
I am having a problem with a combogrid in a form.  What I am doing is to have a drop down selection box and then pass the value to a form to pass to php form.  I can get the drop down combogrid to display but it will not save the value into the database.

Form code:
Code:
<div id="dlg" class="easyui-dialog" style="width: 500px; height:200px; padding:10px 20px"
                                closed="true" buttons="#dlg-buttons">
                                    <div class="ftitle">Code Violations</div>
                                    <form id="fm" method="post" novalidat>
                                        <div class="fitem">
                                        <input id="inspectionId"  name="inspectionId"/>                                            <label>Code Number</label>
                                            <!--<input name="code_number" class="easyui-validatebox" required="true">-->
                                            <input id="cc" class="easyui-combobox" name="code_number"/>
                                            </div>
                                        <div class="fitem">
                                            <label>Description</label>
                                            <input name="description" class="easyui-validatebox" required="true">
                                        </div>
                                    </form>
script code for combogrid:
Code:
<script>
$(function(){
$('#cc').combogrid({
panelWidth:500,
url: 'get_codes.php',
idField: ' id_code_violations',
textField: 'code_number',
mode:'remote',
fitColumns:true,
columns:[[
{field:'id_code_violation',title:'No.',width:25},
{field:'code_number', title:'Code Number', width: 100},
{field:'code_description', title:'Description', width: 400}
]]
});
$("input [name='mode']").change(function(){
var mode = $(this).val();
$('#cc').combogrid({
mode:mode
});
});
});

</script>[/code
Script to process the save/edit/remove:
[code]            <script type="text/javascript">
var url;
function newViolation(){
$('#dlg').dialog('open').dialog('setTitle','New Code Violation');
$('#fm').form('clear');
url = 'save_violation.php';
}
function editViolation(){
var row = $('#dg').datagrid('getSelected');
if (row){
$('#dlg').dialog('open').dialog('setTitle','Edit Violation');
$('#fm').form('load', row);
url = 'update_Violation.php?id='+row.id;
}
}
function saveViolation(){
$('#fm').form('submit',{
url: url,
onSubmit: function(){
return $(this).form('validate');
},
success: function(result){
var result = eval('('+result+')');
if (result.success){

$('#dlg').dialog('close');//closes the dialog window
$('#dg').datagrid('reload');// reload the violations
}else{
$.messager.show({
title:'Error',
msg: result.msg
});
}
}
});
}
function removeViolation(){
var row = $('#dg').datagrid('getSelected');
if (row){
$.messager.confirm('Confirm','Are you sure you want to remove this Violation?', function(r){
if (r){
$.post('remove_vailation.php',{id:row.id}, function(result){
if(result.success){
$('#dg').datagrid('reload');// reload the violation data
}else{
$.messager.show({// show error message
title: 'Error',
msg: result.msg
});
}
},'json');
}
});
}
}
</script>

php code to save:
Code:
<?php 
include 'init.php';
$inspID $_REQUEST['inspectionId'];
$codeNumber $_REQUEST['code_number'];
$description $_REQUEST['description'];

$sql "INSERT into code_violation(inspectionId,code_number, code_description) 
VALUES ('
$inspID','$codeNumber','$description')";
$result = @mysql_query($sql);
if (
$result){
echo json_encode (array('success'=>true));
}else{
echo json_encode (array('msg'=>'some errors occured.'));
}
?>

Please I need help to understand what the problem is.

Thank You[/code]


Title: Re: problem not display of value
Post by: stworthy on April 22, 2013, 12:36:13 AM
Here is your code in the form.
Code:
<input id="cc" class="easyui-combobox" name="code_number"/>

It is the combobox component as described. But at later you re-create it as a combogrid.
Code:
$('#cc').combogrid(...);

What type this component is? Is it a combobox or combogrid? If it is a combogrid, please remove 'class="easyui-combobox"' attribute from the html markup.
Code:
<input id="cc" name="code_number"/>


Title: Re: problem not display of value
Post by: tokick4 on April 22, 2013, 05:38:03 PM
I removed the class from the HTML, it is a combogrid and I can't get the value to of the combogrid pass to the form for input.  When it updates the database it is empty.  Any thought.

Thank you for the reply.

Jon