4 Replies - 493 Views - Last Post: 23 September 2010 - 11:11 AM

#1 czach  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 49
  • Joined: 02-October 09

what's wrong with this?

Posted 20 September 2010 - 01:57 PM

here's my code...

<script>
    var gridimgpath = 'themes/basic/images';

    $("#search").click(function(){
        $value = $("#search_last_name").val();
        $("#list2").trigger("reloadGrid");
        $("#list2").jqGrid({
        url:'http://localhost/bcb/index.php/bcb_c/grid?last_name='+$value,
        datatype: "json",
        colNames:['First Name','Middle Name', 'Last Name'],
        colModel:[
            {name:'first_name',index:'first_name', width:120},
            {name:'middle_name',index:'middle_name', width:120},
            {name:'last_name',index:'last_name', width:120}
        ],
        rowNum:10,
        rowList:[10,20,30],
        pager: jQuery('#pager2'),
        passvalue: '',
        imgpath: gridimgpath,
        viewrecords: true,
        sortorder: "desc"
    });
    });
</script> 


i dont know where the problem is but when i input a value into my text box with the id of "search_last_name", it would still work, but when i try to change value to the same text box.. somehow it retains the value of the first.. any idea whats wrong?

Is This A Good Question/Topic? 0
  • +

Replies To: what's wrong with this?

#2 czach  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 49
  • Joined: 02-October 09

Re: what's wrong with this?

Posted 20 September 2010 - 02:07 PM

i think i know where the problem is.. the '$value' in the 'url:' doesn't seem to be able to change its value.. but i still dont know how to fix it.. >.<
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6036
  • View blog
  • Posts: 23,421
  • Joined: 23-August 08

Re: what's wrong with this?

Posted 20 September 2010 - 02:58 PM

Is $value a PHP variable? If so you must do

url:'http://localhost/bcb/index.php/bcb_c/grid?last_name='+<?php echo $value ?>,

Was This Post Helpful? 2
  • +
  • -

#4 czach  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 49
  • Joined: 02-October 09

Re: what's wrong with this?

Posted 23 September 2010 - 09:24 AM

oh so that's it.. thanks!! but i have another problem.. as you can see in my code, my grid is inside the

$("#search").click


so basically, the grid will only load after i click the button.. i've searched in the net and figured that i could make use of the ".trigger" but it seems that its not functioning. could you help me with this?.. here's my code.

$("#list2").jqGrid({
        url:'http://localhost/bcb/index.php/bcb_c/grid',
        datatype: "json",
        colNames:['id','First Name','Middle Name', 'Last Name', 'Address'],
        colModel:[
            {name: 'id', index:'id', width:20},
            {name:'first_name',index:'first_name', width:120},
            {name:'middle_name',index:'middle_name', width:120},
            {name:'last_name',index:'last_name', width:120},
            {name:'address', index:'address', width:120}
        ],
        rowNum:10,
        rowList:[10,20,30],
        loadonce: true,
        postData: {pass1: '', pass2: ''},
        pager: jQuery('#pager2'),
        width: '550',
        imgpath: gridimgpath,
        scrollrows: true,
        viewrecords: true,
        sortorder: "desc"                 
    });
    
    $("#search").click(function(){
         var last_name = $("#search_last_name");
         var first_name = $("#search_first_name");
            jQuery("#list2").setPostData({pass1: last_name.val(), pass2: first_name.val()});
            jQuery("#list2").setGridParam({url:"http://localhost/bcb/index.php/bcb_c/grid"}).trigger("reloadGrid");
    });

Was This Post Helpful? 0
  • +
  • -

#5 czach  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 49
  • Joined: 02-October 09

Re: what's wrong with this?

Posted 23 September 2010 - 11:11 AM

anyone? :cry2:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1