function katalog() { var ds_grid = new Ext.data.JsonStore({ proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'e_katalog/c_katalog/grid', method: 'POST' }), params: { start: 0, limit: 5 }, root: 'data', totalProperty: 'results', autoLoad: true, fields: [ { name: "id_katalog", mapping: "id_katalog" }, { name: "kd_katalog", mapping: "kd_katalog" }, { name: "nama_pengarang", mapping: "nama_pengarang" }, { name: "nama_kategori", mapping: "nama_kategori" }, { name: "isbn", mapping: "isbn" }, { name: "judul_buku", mapping: "judul_buku" }, { name: "deskripsi", mapping: "deskripsi" }, { name: "tgl_terbit", mapping: "tgl_terbit" }, { name: "thn_terbit", mapping: "thn_terbit" }] }); var cm = new Ext.grid.ColumnModel({ // specify any defaults for each column defaults: { sortable: true // columns are not sortable by default }, columns: [ //new Ext.grid.RowNumberer(), { header: 'Kode Katalog', width: 80, dataIndex: 'kd_katalog', sortable: true }, { header: 'Pengarang', width: 80, dataIndex: 'nama_pengarang', sortable: true }, { header: 'Kategori', width: 80, dataIndex: 'nama_kategori', sortable: true }, { header: 'No.Buku', width: 80, dataIndex: 'isbn', sortable: true }, { header: 'Judul Buku', width: 150, dataIndex: 'judul_buku', sortable: true }, { header: 'Deskripsi', width: 250, dataIndex: 'deskripsi', sortable: true }, { header: 'Tanggal Terbit', width: 80, dataIndex: 'tgl_terbit', sortable: true }, { header: 'Tahun Terbit', width: 80, dataIndex: 'thn_terbit', sortable: true }] }); var vw = new Ext.grid.GridView({ emptyText: '< Katalog Belum Dipilih >' }); var sm_nya = new Ext.grid.CheckboxSelectionModel({ singleSelect:true, listeners: { // rowselect: select_action, // rowdeselect: deselect_action } }); var cari_data = [new Ext.ux.grid.Search({ iconCls: 'btn_search', minChars: 1, autoFocus: true, autoHeight: true, position: 'top', mode: 'local', width: 200 })]; var paging = new Ext.PagingToolbar({ pageSize: 50, store: ds_grid, displayInfo: true, displayMsg: 'Data Materi Dari {0} - {1} of {2}', emptyMsg: 'Katalog Belum Dipilih.' }); // ================================================ var ds_grid2 = new Ext.data.JsonStore({ proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'e_learning/c_tambahmateri/grid_materi_prodi', method: 'POST' }), root: 'data', totalProperty: 'results', autoLoad: true, fields: [{ name: "kdprodi", mapping: "kdprodi" }, { name: "nmprodi", mapping: "nmprodi" }, { name: "pilih", mapping: "pilih", type: 'bool' }] }); var cm2 = new Ext.grid.ColumnModel({ // specify any defaults for each column defaults: { sortable: true // columns are not sortable by default }, columns: [ //new Ext.grid.RowNumberer(), { header: 'Kode Prodi', width: 50, dataIndex: 'kdprodi', sortable: true }, { header: 'Nama Prodi', width: 250, dataIndex: 'nmprodi', sortable: true }, { xtype: 'checkcolumn', header: '
Pilih
', width: 50, dataIndex: 'pilih', sortable: true , editor:{ xtype: 'checkbox', id:'cbpilih', name:'cbpilih', listeners: { change: function() { } } } }] }); var vw2 = new Ext.grid.GridView({ emptyText: '< Prodi Belum Dipilih >' }); var sm_nya2 = new Ext.grid.CheckboxSelectionModel({ listeners: { // rowselect: select_action, // rowdeselect: deselect_action } }); var cari_data2 = [new Ext.ux.grid.Search({ iconCls: 'btn_search', minChars: 1, autoFocus: true, autoHeight: true, position: 'top', mode: 'local', width: 200 })]; var paging2 = new Ext.PagingToolbar({ pageSize: 50, store: ds_grid2, displayInfo: true, displayMsg: 'Data Prodi Dari {0} - {1} of {2}', emptyMsg: 'Prodi Belum Dipilih.' }); // ========================================================= var grid_nya = new Ext.grid.EditorGridPanel({ store: ds_grid, frame: true, //width: 1140, autoScroll: true, autoHeight: true, autoWidth: true, plugins: cari_data, id: 'grid_det_product', buttonAlign: 'left', defaults: { anchor: '-10' }, forceFit: true, tbar: [{ text: 'Add', id: 'btn_add', iconCls: 'silk-add', handler: btn_menu_add }, '-', { text: 'Edit', id: 'btn_edit', iconCls: 'silk-edit', handler: function() { if (sm_nya.getCount() > 0) { var module_id = sm_nya.getSelected().data['id_katalog']; //form_gallery(gallery_id); //alert(module_id); f_tambahkatalog_form(module_id, ds_grid); grid_nya.getSelectionModel().clearSelections() Ext.getCmp('btn_simpan_prodi').disable(); } } }, '-', { text: 'Delete', id: 'btn_delete', iconCls: 'silk-delete', handler: function() { if (sm_nya.getCount() > 0) { var delete_id = sm_nya.getSelected().data['id_katalog']; Ext.MessageBox.show({ title: "Konfirmasi", msg: "Anda Yakin Untuk menghapus Data ini?", buttons: Ext.MessageBox.YESNO, fn: function(btn) { if (btn == 'yes') { Ext.Ajax.request({ url: BASE_URL + 'e_katalog/c_katalog/delete', method: 'POST', success: function() { Ext.MessageBox.alert("Informasi", "Hapus Data Berhasil"); ds_grid.load(); Ext.getCmp('btn_simpan_prodi').disable(); }, failure: function(result) { Ext.MessageBox.alert("Informasi", "Hapus Data Gagal"); }, params: { hapus_id: delete_id } }); } } }); } } }, '-', '->'], sm: sm_nya, vw: vw, cm: cm, bbar: paging, //autoExpandColumn: 'common', clicksToEdit: 1, listeners: { rowclick: function rowClick(grid, rowIdx) { var rec = ds_grid.getAt(rowIdx); isi =rec.data["idmateri"]; if(isi!=''){ Ext.getCmp('btn_simpan_prodi').enable(); ds_grid2.setBaseParam('idmateri', isi); ds_grid2.load(); } else { Ext.getCmp('btn_simpan_prodi').disable(); } } } }); // ================================================================ var grid_nya2 = new Ext.grid.EditorGridPanel({ store: ds_grid2, frame: true, //width: 1140, autoScroll: true, autoHeight: true, autoWidth: true, plugins: cari_data2, id: 'grid_det_product2', buttonAlign: 'left', defaults: { anchor: '-10' }, forceFit: true, tbar: [ { text: 'Simpan', id: 'btn_simpan_prodi', iconCls: 'silk-accept', disabled:true, handler: function() { if (sm_nya.getCount() > 0) { simpanmateriprodi() } else { Ext.MessageBox.alert("Informasi", "Pilih Salah Satu Materi"); } } }, '->'], sm: sm_nya2, vw: vw2, cm: cm2, bbar: paging2, //autoExpandColumn: 'common', clicksToEdit: 1, listeners: { rowdblclick: function rowdblClick(grid, rowIdx) { var rec = ds_grid2.getAt(rowIdx); //alert(rec.data["kdmenu"] + ', ' + Ext.getCmp('combox').getValue()); } } }); var form_bp_general = new Ext.form.FormPanel({ id: 'form_bp_general_id', title: 'Halaman Katalog', region: 'center', autoScroll: true, buttonAlign: 'left', bodyStyle: 'padding: 5px', border: false, waitMsg: 'Waiting...', layout: 'column', items: [{ columnWidth: .90, xtype: 'panel', border: false, bodyStyle: 'padding:0px 0px 0px 0px', items: [{ layout: 'form', border: false, items: [{ xtype: 'fieldset', title: 'Daftar Katalog', layout: 'form', id:'daftarmateri', // labelAlign: 'top', items: [grid_nya] }] }] }, ]} ); function btn_menu_add() { f_tambahkatalog_form('', ds_grid); grid_nya.getSelectionModel().clearSelections() Ext.getCmp('btn_simpan_prodi').disable(); } get_content(form_bp_general); function get_materi_prodi(sm, sm2) { var par=''; var a= 1; var c = ';'; var cntrec = sm.getCount(); var arr = sm.getSelections(); // record grid materi yang dipilih for (i = 0; i < cntrec; i++) { grid_nya2.getStore().each(function(rec){ // ambil seluruh grid prodi var rowData = rec.data; if (a == grid_nya2.getStore().getCount()) { c = '' } var j = (rowData['pilih']) ? 1 : 0; par += arr[i].data['idmateri'] + 'x' + rowData['kdprodi'] + 'x' + j + 'x' + // pilih c; a= a+1; }); return par; } } function simpanmateriprodi(){ var materiprodi = get_materi_prodi(sm_nya,sm_nya2); Ext.Ajax.request({ url: BASE_URL + 'e_learning/c_tambahmateri/simpanmateriprodi', params: { pilihmateriprodi: materiprodi, // }, success: function() { Ext.MessageBox.alert("Informasi", "Simpan Data Berhasil"); ds_grid2.load(); }, failure: function() { Ext.MessageBox.alert("Informasi", "SImpan Data Gagal"); } }); } }