Results 1 to 2 of 2

Thread: Submitting data via a form and loading in a grid

  1. #1

    Default Submitting data via a form and loading in a grid

    hey guys,

    i have a form panel from which i submit certain fields to a method which returns success to the formpanel and that triggers a store.Load() for my grid. my store gets the data from another method called getviolations which has a sql query within it. after executing the query it returns success and the array of the returned recordsets. this is then loaded within a gird. my code is as follows:
    public function submit()
    {
    $site = isset($_GET['site']) ? $_GET['sdate'] : "";
    $sdate = isset($_GET['sdate']) ? $_GET['sdate'] : "";
    $edate = isset($_GET['edate']) ? $_GET['edate'] : "";
    $status = isset($_GET['show_violations']) ? $_GET['show_violations'] "";

    echo '{success:true}';
    }
    public function getviolations(){
    $db = odbc::getDBO();
    $sql = "SELECT TOP 50 CONVERT(VARCHAR(10), DateSubmitted, 120) as vdate, ViolationType as type, isAmnestyRequest as amnesty, IssueResolved as resolved, ViolationResolution as action, Status as status FROM KIR_ViolationDetail, KIR_ViolationGeneral, KIR_Sites WHERE Site='$site' AND DateSubmitted >= '$sdate' AND DateSubmitted <= '$edate' AND Status='$status' ";
    foreach($db->query($sql) as $vrow)
    {
    $v_arr[] = $vrow;
    }

    echo '{success:true,rows:'.json_encode($v_arr).'}';

    }

    <---- javascript on a different page -->

    Ext.onReady(function(){

    var violations = new Ext.data.Store({
    reader:new Ext.data.JsonReader({
    fields:[{
    name: 'vdate',
    type: 'date',
    dateFormat: 'Y-m-d'
    },'type','amnesty','resolved','action','status'],
    root:'rows'

    }),
    proxy: new Ext.data.HttpProxy({
    url:'/kohana/index.php/manage/getviolations'
    })

    });

    var myForm = new Ext.FormPanel({
    url:'/kohana/index.php/manage/submit',
    title:'Reporting',
    height:300,
    border:false,
    bodyStyle:'padding:5px;',
    items:[{

    {
    xtype:'button',
    text:'Submit',
    handler:function(){
    myForm.getForm().submit({
    method:'GET',
    waitTitle:'Loading',
    waitMsg:'Please wait..',
    success : function(){
    violations.load();
    }

    })
    }
    }]



    everything seems correct, however i get the error 'undefined variable $site',by the kohana runtime, also if i replace $site within the sql query with a constant value , the the next variable in the query $sdate shows up as undefined.

    if i combine the submit and getviolations methods i get the error undefined variable $v_arr.



    regards,

    ice

  2. #2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •