function f_tambahmateri() { var ds_grid = new Ext.data.JsonStore({ proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'e_learning/c_tambahmateri/grid', method: 'POST' }), baseParams: { start: 0, limit: 20, userid: USERID }, root: 'data', totalProperty: 'results', autoLoad: true, fields: [{ name: "idmateri", mapping: "idmateri" }, { name: "idmk", mapping: "idmk" }, { name: "nmmk", mapping: "nmmk" }, { name: "idsesi", mapping: "idsesi" }, { name: "nmsesi", mapping: "nmsesi" }, { name: "userid", mapping: "userid" }, { name: "pengguna", mapping: "pengguna" }, { name: "subjek", mapping: "subjek" }, { name: "deskripsi", mapping: "deskripsi" }, { name: "tujuan", mapping: "tujuan" }, { name: "catatan", mapping: "catatan" }, { name: "idstpublish", mapping: "idstpublish" }, { name: "nmstpublish", mapping: "nmstpublish" }, { name: "tglpublish", mapping: "tglpublish" }, { name: "jampublish", mapping: "jampublish" }, { name: "file", mapping: "file" }, { name: "tipe", mapping: "tipe" }, { name: "download", mapping: "download" }], listeners: { load: function(store, records, options) { ds_grid2.setBaseParam('idmateri', ''); ds_grid2.load(); Ext.getCmp('btn_simpan_prodi').disable(); Ext.getCmp('btn_selectall').disable(); Ext.getCmp('btn_deselectall').disable(); } } }); 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: 'Id', width: 30, dataIndex: 'idmateri', sortable: true }, { header: 'Subjek/Judul', width: 75, dataIndex: 'subjek', sortable: true }, { header: 'Sesi', width: 50, dataIndex: 'nmsesi', sortable: true }, { header: 'Matakuliah', width: 100, dataIndex: 'nmmk', sortable: true }, { header: 'Dosen Pengajar', width: 100, dataIndex: 'pengguna', sortable: true }, { header: 'Status Publish', width: 80, dataIndex: 'nmstpublish', sortable: true }, { header: 'Tanggal Publish', width: 80, dataIndex: 'tglpublish', sortable: true }, { header: 'Jam Publish', width: 80, dataIndex: 'jampublish', sortable: true }, { header: 'Download', width: 80, dataIndex: 'download', sortable: true }] }); var vw = new Ext.grid.GridView({ emptyText: '< Materi 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: 20, store: ds_grid, displayInfo: true, displayMsg: 'Data Materi Dari {0} - {1} of {2}', emptyMsg: 'Materi 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: 85, 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: 100 })]; 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['idmateri']; //form_gallery(gallery_id); //alert(module_id); f_tambahmateri_form(module_id, ds_grid); grid_nya.getSelectionModel().clearSelections() Ext.getCmp('btn_simpan_prodi').disable(); Ext.getCmp('btn_selectall').disable(); Ext.getCmp('btn_deselectall').disable(); } } }, '-', { text: 'Delete', id: 'btn_delete', iconCls: 'silk-delete', handler: function() { if (sm_nya.getCount() > 0) { var delete_id = sm_nya.getSelected().data['idmateri']; 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_learning/c_tambahmateri/delete', method: 'POST', success: function() { Ext.MessageBox.alert("Informasi", "Hapus Data Berhasil"); ds_grid.load(); Ext.getCmp('btn_simpan_prodi').disable(); Ext.getCmp('btn_selectall').disable(); Ext.getCmp('btn_deselectall').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(); Ext.getCmp('btn_selectall').enable(); Ext.getCmp('btn_deselectall').enable(); ds_grid2.setBaseParam('idmateri', isi); ds_grid2.load(); } else { Ext.getCmp('btn_simpan_prodi').disable(); Ext.getCmp('btn_selectall').disable(); Ext.getCmp('btn_deselectall').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-save', disabled:true, handler: function() { if (sm_nya.getCount() > 0) { simpanmateriprodi() } else { Ext.MessageBox.alert("Informasi", "Pilih Salah Satu Materi"); } } }, { text: 'Select All', id: 'btn_selectall', iconCls: 'silk-accept', disabled:true, handler: function() { selectall() } }, { text: 'Deselect All', id: 'btn_deselectall', iconCls: 'silk-delete', disabled:true, handler: function() { deselectall() } }, '->'], 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: 'Tambah Materi', region: 'center', autoScroll: true, buttonAlign: 'left', bodyStyle: 'padding: 5px', border: false, waitMsg: 'Waiting...', layout: 'column', items: [{ columnWidth: .63, xtype: 'panel', border: false, bodyStyle: 'padding:0px 0px 0px 0px', items: [{ layout: 'form', border: false, items: [{ xtype: 'fieldset', title: 'Daftar Materi', layout: 'form', id:'daftarmateri', // labelAlign: 'top', items: [grid_nya] }] }] }, { columnWidth: .37, xtype: 'panel', border: false, bodyStyle: 'padding:0px 0px 0px 0px', items: [{ layout: 'form', border: false, items: [{ xtype: 'fieldset', title: 'Untuk Program Studi', layout: 'form', id:'daftarprodi', items: [grid_nya2] }] }] }] }); function btn_menu_add() { f_tambahmateri_form('', ds_grid); grid_nya.getSelectionModel().clearSelections() Ext.getCmp('btn_simpan_prodi').disable(); Ext.getCmp('btn_selectall').disable(); Ext.getCmp('btn_deselectall').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"); } }); } //select all function selectall(){ var materiprodi = get_materi_prodi(sm_nya,sm_nya2); Ext.Ajax.request({ url: BASE_URL + 'e_learning/c_tambahmateri/selectallprodi', params: { pilihmateriprodi: materiprodi, }, success: function() { Ext.MessageBox.alert("Informasi", "Select All Program Studi"); ds_grid2.load(); }, failure: function() { Ext.MessageBox.alert("Informasi", "Select All Program Studi Gagal"); } }); } //deselect all function deselectall(){ var materiprodi = get_materi_prodi(sm_nya,sm_nya2); Ext.Ajax.request({ url: BASE_URL + 'e_learning/c_tambahmateri/deselectallprodi', params: { pilihmateriprodi: materiprodi, }, success: function() { Ext.MessageBox.alert("Informasi", "Deselect All Program Studi"); ds_grid2.load(); }, failure: function() { Ext.MessageBox.alert("Informasi", "Deselect All Program Studi Gagal"); } }); } }