Jump to content

UnimDBListGrid How to get back Value from Spin Edit


Masteritec

Recommended Posts

function beforeInit(sender, config)
{    
   config.loadingText='Loading...';
   config.grouped=false;
   
   
   config.itemTpl= new Ext.XTemplate(
             '<tr><td><span style="font-size:18px;font-weight:bold;padding-top:4px;padding-left:5px;">{0}</span></td></tr>'+
             '<table class="tblstock">'+             
                  '<tr>' +
                     '<td>'+                        
                        '<img src={5} width="120" height="120"/>' +
                     '</td>'+
                       
                     '<td>'+  
                        '<table class="tblStockDescr">' +                               
                            '<tr><td style="font-size:13px;padding-top:4px;padding-left:5px;line-height:1.2;">{1}{2}</td></tr>'+     
                            '<tr><td style="font-size:13px;font-weight:bold;color:black;padding-top:4px;padding-left:5px;line-height:0.8;">Balance : {4}</td></tr>'+                                                             
                            '<tr><td style="font-size:13px;font-weight:bold;color:blue;padding-top:4px;padding-left:5px;line-height:0.8;">MYR 999,999.99</td></tr>'+
                            '<tr><td><input type="number" id="seqty" value="1" min="1" /></td></tr>' +                              
                            '<tr><td><input type="button" class="addtocartbutton" value="Add to Cart" data-id="{0}"></td></tr>' +                                                                                                                       
                        '</table>' +
                                                           
                     '</td>' +
                     
                  '</tr>' +                               
                                                                                                                                                     
             '</table>'                                                                       
   );     
                             
}

 

function afterCreate(sender)
{
 Ext.getCmp(sender.id).bodyElement.addListener('click', function(event, target) {
       
        if (target.getAttribute('class') === 'addtocartbutton') {
            var qty = 12;   <== How to get back value from spin edit ID seqty?
            ajaxRequest(sender, "ADDTOCART", ['stockcode='+target.getAttribute('data-id'), 'qty='+qty]);
        }
    }, null, {
        delegate: 'table input'
    });
}

 

 

 

WhatsApp Image 2020-11-03 at 11.13.08 PM.jpeg

Link to comment
Share on other sites

24 minutes ago, Sherzod said:

Hello,

Can you please explain in more details. Testcase?

Current i able to return {0} to AjaxRequest when click Add to Cart Button,

 

Beside that , i also need usert to input quantity using Spin edit, then only click Add to Cart then return to AjaxRequest,

 

I don't know to pass spin edit value to ajax request.

Please help

Link to comment
Share on other sites

13 minutes ago, Masteritec said:

Unigui_Mobile_Listview.zip 64.58 kB · 0 downloads

Try these changes:

function beforeInit(sender, config)
{    
   config.loadingText='Loading...';
   config.grouped=false;
   
   
   config.itemTpl= new Ext.XTemplate(
             '<tr><td><span style="font-size:18px;font-weight:bold;padding-top:4px;padding-left:5px;">{0}</span></td></tr>'+
             '<table class="tblstock">'+             
                  '<tr>' +
                     '<td>'+                        
                        '<img src={5} width="120" height="120"/>' +
                     '</td>'+
                       
                     '<td>'+  
                        '<table class="tblStockDescr">' +                               
                            '<tr><td style="font-size:13px;padding-top:4px;padding-left:5px;line-height:1.2;">{1}{2}</td></tr>'+     
                            '<tr><td style="font-size:13px;font-weight:bold;color:black;padding-top:4px;padding-left:5px;line-height:0.8;">Balance : {4}</td></tr>'+                                                             
                            '<tr><td style="font-size:13px;font-weight:bold;color:blue;padding-top:4px;padding-left:5px;line-height:0.8;">MYR 999,999.99</td></tr>'+
                            '<tr><td><input type="number" id="seqty{0}" value="1" min="1" /></td></tr>' +                              
                            '<tr><td><input type="button" class="addtocartbutton" value="Add to Cart" data-id="{0}"></td></tr>' +                                                                                                                       
                        '</table>' +
                                                           
                     '</td>' +
                     
                  '</tr>' +                               
                                                                                                                                                     
             '</table>'                                                                       
   );     
                             
}
function afterCreate(sender)
{
 Ext.getCmp(sender.id).bodyElement.addListener('click', function(event, target) {
       
        if (target.getAttribute('class') === 'addtocartbutton') {
            var qty = 12;
            ajaxRequest(sender, "ADDTOCART", ['stockcode='+target.getAttribute('data-id'), 'qty='+Ext.get("seqty"+target.getAttribute('data-id')).getValue()]);
        }
    }, null, {
        delegate: 'table input'
    });
}

 

Link to comment
Share on other sites

6 hours ago, Sherzod said:

Try these changes:


function beforeInit(sender, config)
{    
   config.loadingText='Loading...';
   config.grouped=false;
   
   
   config.itemTpl= new Ext.XTemplate(
             '<tr><td><span style="font-size:18px;font-weight:bold;padding-top:4px;padding-left:5px;">{0}</span></td></tr>'+
             '<table class="tblstock">'+             
                  '<tr>' +
                     '<td>'+                        
                        '<img src={5} width="120" height="120"/>' +
                     '</td>'+
                       
                     '<td>'+  
                        '<table class="tblStockDescr">' +                               
                            '<tr><td style="font-size:13px;padding-top:4px;padding-left:5px;line-height:1.2;">{1}{2}</td></tr>'+     
                            '<tr><td style="font-size:13px;font-weight:bold;color:black;padding-top:4px;padding-left:5px;line-height:0.8;">Balance : {4}</td></tr>'+                                                             
                            '<tr><td style="font-size:13px;font-weight:bold;color:blue;padding-top:4px;padding-left:5px;line-height:0.8;">MYR 999,999.99</td></tr>'+
                            '<tr><td><input type="number" id="seqty{0}" value="1" min="1" /></td></tr>' +                              
                            '<tr><td><input type="button" class="addtocartbutton" value="Add to Cart" data-id="{0}"></td></tr>' +                                                                                                                       
                        '</table>' +
                                                           
                     '</td>' +
                     
                  '</tr>' +                               
                                                                                                                                                     
             '</table>'                                                                       
   );     
                             
}

function afterCreate(sender)
{
 Ext.getCmp(sender.id).bodyElement.addListener('click', function(event, target) {
       
        if (target.getAttribute('class') === 'addtocartbutton') {
            var qty = 12;
            ajaxRequest(sender, "ADDTOCART", ['stockcode='+target.getAttribute('data-id'), 'qty='+Ext.get("seqty"+target.getAttribute('data-id')).getValue()]);
        }
    }, null, {
        delegate: 'table input'
    });
}

 

Thanks your help

Link to comment
Share on other sites

On 11/4/2020 at 3:48 AM, Sherzod said:

Try these changes:


function beforeInit(sender, config)
{    
   config.loadingText='Loading...';
   config.grouped=false;
   
   
   config.itemTpl= new Ext.XTemplate(
             '<tr><td><span style="font-size:18px;font-weight:bold;padding-top:4px;padding-left:5px;">{0}</span></td></tr>'+
             '<table class="tblstock">'+             
                  '<tr>' +
                     '<td>'+                        
                        '<img src={5} width="120" height="120"/>' +
                     '</td>'+
                       
                     '<td>'+  
                        '<table class="tblStockDescr">' +                               
                            '<tr><td style="font-size:13px;padding-top:4px;padding-left:5px;line-height:1.2;">{1}{2}</td></tr>'+     
                            '<tr><td style="font-size:13px;font-weight:bold;color:black;padding-top:4px;padding-left:5px;line-height:0.8;">Balance : {4}</td></tr>'+                                                             
                            '<tr><td style="font-size:13px;font-weight:bold;color:blue;padding-top:4px;padding-left:5px;line-height:0.8;">MYR 999,999.99</td></tr>'+
                            '<tr><td><input type="number" id="seqty{0}" value="1" min="1" /></td></tr>' +                              
                            '<tr><td><input type="button" class="addtocartbutton" value="Add to Cart" data-id="{0}"></td></tr>' +                                                                                                                       
                        '</table>' +
                                                           
                     '</td>' +
                     
                  '</tr>' +                               
                                                                                                                                                     
             '</table>'                                                                       
   );     
                             
}

function afterCreate(sender)
{
 Ext.getCmp(sender.id).bodyElement.addListener('click', function(event, target) {
       
        if (target.getAttribute('class') === 'addtocartbutton') {
            var qty = 12;
            ajaxRequest(sender, "ADDTOCART", ['stockcode='+target.getAttribute('data-id'), 'qty='+Ext.get("seqty"+target.getAttribute('data-id')).getValue()]);
        }
    }, null, {
        delegate: 'table input'
    });
}

 

 

 

@Sherzod

Attached is test case source code & Video for you to refer.

Above code only ok for first time form show.

Refer video

First time click Show Cart -> Select 1221 -> Change Value to 5 -> Add to Cart -> ajaxRequest Show Message Correct.

Close the Sreen

Second time  click Show Cart -> Select 1221 -> Screen value no change default to 1 -> Add to Cart -> ajaxRequest Show Message wrong

it take back previos value and now whatever value you change it always show 5 only

Please help

 

 

 

Unigui_Mobile_Listview2.7z

Link to comment
Share on other sites

3 hours ago, Masteritec said:

it take back previos value and now whatever value you change it always show 5 only

Try this approach:

function beforeInit(sender, config)
{    
   config.loadingText='Loading...';
   config.grouped=false;
   
   
   config.itemTpl= new Ext.XTemplate(
             '<tr><td><span style="font-size:18px;font-weight:bold;padding-top:4px;padding-left:5px;">{0}</span></td></tr>'+
             '<table class="tblstock">'+             
                  '<tr>' +
                     '<td>'+                        
                        '<img src={5} width="120" height="120"/>' +
                     '</td>'+
                       
                     '<td>'+  
                        '<table class="tblStockDescr">' +                               
                            '<tr><td style="font-size:13px;padding-top:4px;padding-left:5px;line-height:1.2;">{1}{2}</td></tr>'+     
                            '<tr><td style="font-size:13px;font-weight:bold;color:black;padding-top:4px;padding-left:5px;line-height:0.8;">Balance : {4}</td></tr>'+                                                             
                            '<tr><td style="font-size:13px;font-weight:bold;color:blue;padding-top:4px;padding-left:5px;line-height:0.8;">MYR 999,999.99</td></tr>'+
                            '<tr><td><input type="number" id="'+ config.id +'_seqty{0}" value="1" min="1" /></td></tr>' +                              
                            '<tr><td><input type="button" class="addtocartbutton" value="Add to Cart" data-id="{0}"></td></tr>' +                                                                                                                       
                        '</table>' +
                                                           
                     '</td>' +
                     
                  '</tr>' +                               
                                                                                                                                                     
             '</table>'                                                                       
   );     
                             
}
function afterCreate(sender)
{
 Ext.getCmp(sender.id).bodyElement.addListener('click', function(event, target) {
       
        if (target.getAttribute('class') === 'addtocartbutton') {
 
            ajaxRequest(sender, "ADDTOCART", ['stockcode='+target.getAttribute('data-id'), 'qty='+Ext.get(sender.id+"_seqty"+target.getAttribute('data-id')).getValue()]);
        }
    }, null, {
        delegate: 'table input'
    });
}

 

Link to comment
Share on other sites

  • 1 year later...
×
×
  • Create New...