Pages

Tampilkan postingan dengan label Ext JS. Tampilkan semua postingan
Tampilkan postingan dengan label Ext JS. Tampilkan semua postingan

Rabu, 29 Agustus 2012

Ext.ux.data.PagingStore problem with empty store

I'm using Ext.ux.data.PagingStore extension made by Condor because I need local store for paging my ExtJs grid. But, there is problem with this extension. The grid paging toolbar always set the current page cursor at page 2 while the store is empty.

After searching at sencha forum, I've found this solution was succesfully solve my problem with Ext.ux.data.PagingStore.

Just add a constructor for Ext.ux.data.PagingStore:
constructor: function(config) {
        this.totalLength = 0;
        Ext.ux.data.PagingStore.superclass.constructor.call(this, config);
},

and ... At the beginning of the Ext.ux.PagingToolbar's onChange method:
Change the code
if (this.cursor >= t) {
     this.cursor = Math.ceil((t + 1) / s) * s;
}
into like this:
if (this.cursor >= t && this.cursor > 0) {
     this.cursor = Math.ceil((t + 1) / s) * s;
}




The link to sencha forum thread is:
http://www.sencha.com/forum/showthread.php?71532-Ext.ux.data.PagingStore-v0.5&p=624509&viewfull=1#post624509

Hopefully that save your headache too.. :)
Baca selengkapnya...

Sabtu, 13 Agustus 2011

Membaca JSON dengan Ext JS

Ext JS memiliki fungsi yang memudahkan kita untuk membaca Call Back hasil request Ajax.

Dengan menggunakan fungsi decode(), sangat memudahkan kita membaca data JSON bahkan tanpa melakukan mapping sekalipun.

Misalnya callback ajax request menghasilkan JSON seperti berikut:
{"success":true,"data":[{"idpegawai":"8503030WB", "namapegawai":"Yudhi Armyndharis", "alamat":"Batam"}]}
Maka kita dapat mengambil data nama pegawai dengan cara seperti berikut:
Ext.Ajax.request({
	url: 'store/datapegawai.php',
	params: {
	    action: 'read',
	    idpegawai: '8503030WB'
	},
	success: function(resp, opt){ 
		var callbackdata = Ext.util.JSON.decode(resp.responseText.trim());
		//ambil namapegawai dan simpan sebagai variable
		var namapegawai = callbackdata.data[0].namapegawai;
		//tampilkan di console
		console.log(namapegawai);
	},
	failure: function(resp,opt) { 
	    Ext.Msg.alert('Error','Database server error..'); 
	}
});
Baca selengkapnya...