function st_tahapan(){ var fields_kel_biaya = RH.storeFields('idsttahapan','kdsttahapan','nmsttahapan'); var pageSize = 18; var ds_kel_biaya = RH.JsonStore({ url : BASE_URL + 'st_tahapan_controller/get_sttahapan', fields : fields_kel_biaya, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_biaya = RH.searchComp({ id : 'sb_biaya', fields : ['kdsttahapan:Kode','nmsttahapan:Nama'], selected : 'nmsttahapan', store : ds_kel_biaya }); // COLUMN MODEL var cm_biaya = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Kode'),width: 100, dataIndex: 'kdsttahapan', sortable: true }, { header: RH.h3('Nama'), width: 300, dataIndex: 'nmsttahapan', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_kel_biaya = RH.GridPanel_T1({ ds: ds_kel_biaya, cm: cm_biaya, singleSelect: true, searchComp: sb_biaya, allowAdd: true, fnAdd: fnAddKelbiaya, pageSize: pageSize, cellclick: onCellJbiayaClick }); var fp_biaya = RH.GPContainer1({ title: 'Status Tahapan', iconCls:'silk-house', gridPanel: gp_kel_biaya, }); SET_PAGE_CONTENT(fp_biaya); /** FUNCTIONS */ function onCellJbiayaClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditJbiaya(grid, record)}); RH.DeleteClick(e, function(){fnDeleteJbiaya(grid, record)}); } function reloadKelbiaya(){ ds_kel_biaya.reload(); } function fnAddKelbiaya(){ var grid = gp_kel_biaya; wEntryKelbiaya(false, grid, null); } function fnEditJbiaya(grid, record){ wEntryKelbiaya(true, grid, record); } function fnDeleteJbiaya(grid, record){ var url = BASE_URL + 'st_tahapan_controller/delete_sttahapan'; var params = new Object({ idsttahapan : record.data['idsttahapan'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT JENIS BIAYA */ function wEntryKelbiaya(isUpdate, grid, record){ var winTitle = (isUpdate)?'Status Tahapan (Edit)':'Status Tahapan (Entry)'; /** DATA SOURCE GRUP JENIS BIAYA */ /*var ds_grup = new Ext.data.JsonStore({ //static data fields: [{ name:'kode' }, { name:'nama' }], data: [ { "kode":"1","nama":"test1"}, { "kode":"2","nama":"test2"} ] });*/ /** FORM ENTRY/EDIT MATA-KULIAH */ var kel_biaya_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.kelbiaya', buttonAlign: 'left', labelWidth: 150, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 120, width: 500, layout: 'form', frame: false, defaultType:'textfield', items: [ { id: 'kode_st', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ id: 'nama_st', fieldLabel: 'Nama', width: 200, allowBlank: false, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveKelbiaya(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wJbiaya.close(); } }] }); var wJbiaya = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [kel_biaya_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setJbiayaForm(isUpdate, record); wJbiaya.show(); /** FORM FUNCTIONS */ function setJbiayaForm(isUpdate, record){ //var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ //RH.disableComp('tf.frm.kdjnsbiaya'); RH.setCompValue('kode_st', record.data['kdsttahapan']); RH.setCompValue('nama_st', record.data['nmsttahapan']); return; } } } function fnSaveKelbiaya(){ var idForm = 'frm.kelbiaya'; var sUrl = BASE_URL +'st_tahapan_controller/insert_sttahapan'; var sParams = new Object({ kdsttahapan : RH.getCompValue('kode_st'), nmsttahapan : RH.getCompValue('nama_st'), }); var msgWait = 'Tunggu, sedang proses menyimpan...'; var msgSuccess = 'Tambah data berhasil'; var msgFail = 'Tambah data gagal'; var msgInvalid = 'Data belum valid (data primer belum terisi)!'; if(isUpdate){ sUrl = BASE_URL +'st_tahapan_controller/update_sttahapan'; sParams.idsttahapan = record.data['idsttahapan']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wJbiaya, msgWait, msgSuccess, msgFail, msgInvalid); } }