Results 1 to 2 of 2

Thread: Conditional Save Button on Form Window

  1. #1
    Sencha User
    Join Date
    Jul 2011
    Posts
    49

    Default Conditional Save Button on Form Window

    There is a form window after clicking the item on grid panel.

    Inside the form window, there is a Save button. I want to hide that button depend on certain condition by doing query to database. I have the codes in .js.php file.

    The problem, is, how to get (let's say) id_item value and then put it into a SQL query?

    Any advices and solution will be apprectiated.

    Thanks in advance.

    Here are the codes that failed:

    Code:
            <?
            $sql_active = "select id_item, status from tb_item where id_item = ".$ID;
            $active = $db->fetchRow($sql_active);
            if ($active["status"] <> 1 ) { } else { ?>
             buttons:[{
                text:'Save',
                scope:this,
                 handler:function(){
                    this.getForm().getEl().dom.action='item/item/add/';
                    var me = this;
                    this.getForm().submit(
                    {
                        
                        method:'POST',
                        waitMsg:'Loading..',
                        success:function(){
                            Ext.MessageBox.alert('Status','Successfully saved',function(btn,text){
                                if(btn =='ok'){
                                    me.windowX.item_grid.load({params:{start:0, limit: <? echo $row_item; ?>}});
                                    me.windowX.close();
                                }
                            });
                        },
                        failure:function(){
                            Ext.Msg.alert ('Status','Fail Saved',function(btn,text){
                            });
                        }
                        
                    });
                    
                }
            }]
        <? } ?>

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410

    Default

    You can make an ajax call to the server and have to server return the value and check the success

    Code:
    $sql = 'SELECT * FROM table WHERE ...' ;
    $result = mysql_query($sql); // check result array for values
    Regards,
    Scott.

Tags for this Thread

Posting Permissions

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