-
2 May 2008 12:15 PM #1
Ext.MessageBox.alert problem
Ext.MessageBox.alert problem
hi all,
i'm using startmenu desktop 2.0. in here i have a grid that shows bill that still needs to be paid or are already paid.
i also made it that when bills are due for example tomorrow and a the ext.MessageBox.alert will show up and mention it.
now my problem is this.
when there are for example 2 bills due tomorrow, in the ext.MessageBox.alert it will say Electricity $200, trash $134.
how can i get rid of the ','
see attachment.
this is my code to get what bills are due:
thanks in advance,PHP Code:billdue = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'php/database.php'
}),
baseParams:{task: "BILLDUE"},
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'id'
},['id','name','amount','due'])
});
billdue.load();
billdue.on('load',function() {
var name = [];
for(i = 0; i< billdue.getCount(); i++){
name.push(billdue.getAt(i).data.name + ' - $' + billdue.getAt(i).data.amount + ' Due:' + billdue.getAt(i).data.due +'<br>');
}
Ext.MessageBox.alert('Bills Due !!','the following bills are due: <br><br><b>' + name + '</b>');
});
Robin30Last edited by brian.moeskau; 2 May 2008 at 9:09 PM. Reason: moved to 2.0 forum as requested
-
2 May 2008 1:50 PM #2
MJ
API Search || Ext 3: docs-demo-upgrade guide || User Extension Repository
Frequently Asked Questions: FAQs
Tutorial: Grid (php/mysql/json) , Application Design and Structure || Extensions: MetaGrid, MessageWindow
-
2 May 2008 4:15 PM #3
thanks
thanks
thanks for your answer,
but if i do this,
only the first one will show up. for example only electricity and not trash.PHP Code:Ext.MessageBox.alert('Bills Due !!','the following bills are due: <br><br><b>' + name.shift() + '</b>');
Thanks again.
really appreciate your help.
Regards,
robin
-
2 May 2008 4:43 PM #4
You built an array, name. Then you concatenate it, so it converts the array to a string (including the comma delimiters).
Look at the description I sent you, it says
I'm not saying either is a solution, I was more pointing you towards to the basis of your problem.The shift() method is used to remove and return the first element of an array.
I think I may have approached it differently:
PHP Code:var bills = '';
for(i = 0; i< billdue.getCount(); i++){
bills += billdue.getAt(i).data.name + ' - $' + billdue.getAt(i).data.amount + ' Due:' + billdue.getAt(i).data.due +'<br/>';
}
Ext.MessageBox.alert('Bills Due !!','the following bills are due: <br><br><b>' + bills + '</b>');
MJ
API Search || Ext 3: docs-demo-upgrade guide || User Extension Repository
Frequently Asked Questions: FAQs
Tutorial: Grid (php/mysql/json) , Application Design and Structure || Extensions: MetaGrid, MessageWindow
-
2 May 2008 9:20 PM #5
Same concept, slightly optimized:
Code:var msg = 'The following bills are due: <br>'; for(i = 0, len = billdue.getCount(); i < len; i++){ var bill = billdue.getAt(i).data; msg += ('<br><b>' + bill.name + ' - $' + bill.amount + ' Due:' + bill.due +'</b>'); } Ext.MessageBox.alert('Bills Due !!', msg);
-
3 May 2008 3:58 AM #6
thanks guys
thanks guys
ugh, why do i always have to think difficult when it can be done simple? lol
It works,
Appreciate your help guys.
Thanks,
Regards,
Robin30


Reply With Quote