Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Grid Link

  1. #1

    Default Grid Link

    What im trying to do is when you click this link, i need it to call a php script which it does but its throwing an error saying im doing it wrong. not sure where.

    Code:
    { header: "Delete", 
        width: 8, 
        sortable: true,
        dataIndex: 'delete',
        renderer:  function(quote) {
          return '<a href = # onClick="deletequote("quote")">Remove</a>';
         }}],
    Thats what in the grid, The command it calls is as follows.

    Code:
    function deletequote(quote)
      {
       input_box=confirm("Are you sure you want to delete this?");
       if (input_box==true)
      { 
       window.location="php/deletequote.php?id=" + quote; 
      }
      else
     {
     return false;
     }
    }
    What i need it to do is i need it to ask me if i want to remove / change the area that this SQL command belongs. but its telling me that its syntax error. any ideas? Thanks

  2. #2

  3. #3

    Default

    I figured it was something like that but im having a hell of a time finding any kinda example that shows a link involved in that, i need an active link that i can call or a button or some sort of something to know that its a link.

    follow what im saying? Thanks

  4. #4
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Have you followed those links?

    That is what you should be using.

  5. #5
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

  6. #6

    Default

    Ok, so ive tried a diffrent approch, im trying to do it the same way i delete an item, but instead of deleting i want it to update and change a specific SQL Query item.

    IE:
    Javascript
    Code:
    function handleRemove() {
     
        var selectedKeys = mainquotesGrid.selModel.selections.keys; 
        if(selectedKeys.length > 0)
        {
          Ext.MessageBox.confirm('Message','Do you really want to remove quote?', removeRecord);
        }
        else
        {
          Ext.MessageBox.alert('Message','Please select at least one item to delete');
        }
    }; 
    function removeRecord(btn) {
      if(btn=='yes')
      {
     
        var selectedRows = mainquotesGrid.selModel.selections.items;
        var selectedKeys = mainquotesGrid.selModel.selections.keys; 
        var encoded_keys = Ext.encode(selectedKeys);
     
        Ext.Ajax.request( //alternative to Ext.form.FormPanel? or Ext.BasicForm.submit
          {   
           waitMsg: 'Saving changes...',
           url: 'php/gridoptions.php',
           params: { 
                 task: "remove", 
                 quote: encoded_keys,
                 key: quote_number 
                 },
     
           callback: function (options, success, response) {
                 if (success) { 
                     Ext.MessageBox.alert('OK',response.responseText);
                     var json = Ext.util.JSON.decode(response.responseText);
                     Ext.MessageBox.alert('OK',json.remove_count + ' record(s) deleted.');
     
                 } else{
                   Ext.MessageBox.alert('Sorry, please try again.   [Q304]',response.responseText);
                 }
               },
     
               failure:function(response,options){
               Ext.MessageBox.alert('Warning','Oops...');
                },                                      
               success:function(response,options){
     
               mainquoteStore.reload();
               }                                      
              } 
           ); 
        };
      };
    Thats the Javascript, here is the PHP

    PHP Code:
    function removeData()
    {
        
    $arr $_POST['quote'];
        
    $key $_POST['key'];
        
    $count 0;

        if (
    version_compare(PHP_VERSION,"5.2","<"))
        {    
            require_once(
    "JSON.php"); 
            
    $json = new Services_JSON();
            
    $selectedRows $json->decode(stripslashes($arr));
        } else
        {
            
    $selectedRows json_decode(stripslashes($arr));
        }
        foreach(
    $selectedRows as $row_id)
        {
         
    $id = (integer) $row_id;
         
    $query 'UPDATE `'.$table.'` SET `'.$field.'` = \''.$value.'\' WHERE `'.$key.'` = '.$id;
         
    $result mysql_query($query); /
           if (
    $result$count++;
        }
        
        if (
    $count) { /
            
    $cb = isset($_GET['callback']) ? $_GET['callback'] : '';
               
            
    $response = array('success'=>$count'remove_count'=>$count);

            if (
    version_compare(PHP_VERSION,"5.2","<"))
            {    
                
    $json_response $json->encode($response);
            } else
            {
                
    $json_response json_encode($response);
            }
            echo 
    $cb $json_response;
        } else {
            echo 
    '{failure: true}';
        }

    The Area in red is the query, but when its the normal delete function it works like a charm but it seems like when its not deleting and is only updating it causes the javascript or the php script somehwere to not be able to read the checked items, it goes through all the motions and then says unidentified items removed instead of (#) of items removed which inreturn causes the script to fail and not remove anything. Any ideas? Thanks

  7. #7
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    So what does the returned packet look like in Firebug?

  8. #8

    Default

    Returns the IDs its supose to, thats whats really making me wana beat my head on a wall, its returning everythings its supose to so its something to do with the PHP, but as far as my knowledge goes i dont see anything wrong there. all i did was change the php command from my Delete function so instead of deleting it just changes the field set. any ideas?

  9. #9
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    I dont understand.

  10. #10

    Default

    When i click the Checks, and i click on the button that is suposse to remove the IDs and change thier status, which would move them off that grid, when it sends it it sends the proper IDs and the proper command, but something isnt flowing right on the php side, all i did which worked before is i changed it from fully deleting the ID to just updating the ID and now it doesnt work.

    i cant show you much code then what i displayed already because what i displayed is all the code.

    any ideas? Thanks

Page 1 of 2 12 LastLast

Posting Permissions

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