Carina Marlene Posted May 23, 2012 at 02:05 PM Report #457619 Posted May 23, 2012 at 02:05 PM (edited) Ola antes de mais 🙂 O meu problema é o seguinte: - eu fiz um donwoald de um templatezinho de uma datagrid com subgrids, e ja liguei á base de dados ta a funcionar, so que eu nao preciso so de uma subgrid, ou seja dentro dessa subgrid queria que aparecem, nao só uma tabela como aparece mas 3. Nao domino o javascript de maneira alguma, como nao consigo colocar subgrids de 3 niveis, estava a arranjar outra forma de me mostrar as outras tabelas, colocando um botao que me fizesse aparecer um painel, so que nem o butao estou a conseguir colocar. O código que tenho é este: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="keywords" content="jquery,ui,easy,easyui,web"> <meta name="description" content="easyui help you build your web page easily!"> <title>Datagrid</title> <link rel="stylesheet" type="text/css" href="css/easyui.css"> <link rel="stylesheet" type="text/css" href="css/icon.css"> <link rel="stylesheet" type="text/css" href="css/demo.css"> <script type="text/javascript" src="scripts/jquery-1.4.4.min.js"></script> <script type="text/javascript" src="scripts/jquery.easyui.min.js"></script> <script type="text/javascript" src="scripts/datagrid-detailview.js"></script> <script type="text/javascript"> $(function(){ $('#dg').datagrid({ view: detailview, detailFormatter:function(index,row){ return '<div style="padding:2px"><table id="ddv-' + index + '"></table></div>'; }, onExpandRow: function(index,row){ $('#ddv-'+index).datagrid({ url:'datagrid22_getdetail.php?itemid='+row.id, fitColumns:'true', singleSelect:'true', height:'auto', rownumbers:'true', columns:[[ <!--relativamente á subgrid1--> {field:'aprovado',title:'Aprovado',width:50}, {field:'desprm',title:'Desprm',width:250}, {field:'datprm',title:'Datprm',width:100}, {field:'numprm',title:'Numprm',width:100}, ]], onResize:function(){ $('#dg').datagrid('fixDetailRowHeight',index); }, onSelect:function(){ alert("ola"); }, onLoadSuccess:function(){ setTimeout(function(){ $('#dg').datagrid('fixDetailRowHeight',index); },0); } }); $('#dg').datagrid('fixDetailRowHeight',index); } }); }); </script> </head> <body> <center> <!--tabela principal--> <table id="dg" style="width:1200px;height:500px" url="datagrid22_getdata.php" title="DataGrid - SubGrid" singleSelect="true" fitColumns="true" rownumbers="true" toolbar="#tb" pagination="true"> <thead> <tr> <th field="numordfab" width="20">numordfab</th> <th field="datordfab" width="20">Datordfab</th> <th field="ficof" width="20">Ficof</th> <th field="especificacao" width="100">>Especificacao</th> </tr> </thead> </table> <div id="tb" style="padding:3px"> <span>NR OF:</span> <input id="numordfab" style="line-height:26px;border:1px solid #ccc"> <span>Data OF:</span> <input id="datordfab" style="line-height:26px;border:1px solid #ccc"> <span>FICOF:</span> <input id="ficof" style="line-height:26px;border:1px solid #ccc"> </div> </body> </html> Séra que me podiam dar uma ajuda? O mesmo uma opiniao, existindo outra forma para mostrar as respectivas tabelas ? Muitissimo obrigada pela atenção prestada 😄 Edited May 25, 2012 at 10:40 AM by brunoais geshi!
marciofilipe Posted May 23, 2012 at 02:41 PM Report #457631 Posted May 23, 2012 at 02:41 PM import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.DefaultCellEditor; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.UIManager; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableCellRenderer; public class JButtonTableExample extends JFrame { public JButtonTableExample() { super("exemplo"); DefaultTableModel dm = new DefaultTableModel(); dm.setDataVector(new Object[][] { { "button 1", "foo" }, { "button 2", "bar" } }, new Object[] { "Button", "String" }); JTable table = new JTable(dm); table.getColumn("Button").setCellRenderer(new ButtonRenderer()); table.getColumn("Button").setCellEditor( new ButtonEditor(new JCheckBox())); JScrollPane scroll = new JScrollPane(table); getContentPane().add(scroll); setSize(400, 100); setVisible(true); } public static void main(String[] args) { JButtonTableExample frame = new JButtonTableExample(); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); } } class ButtonRenderer extends JButton implements TableCellRenderer { public ButtonRenderer() { setOpaque(true); } public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (isSelected) { setForeground(table.getSelectionForeground()); setBackground(table.getSelectionBackground()); } else { setForeground(table.getForeground()); setBackground(UIManager.getColor("Button.background")); } setText((value == null) ? "" : value.toString()); return this; } } class ButtonEditor extends DefaultCellEditor { protected JButton button; private String label; private boolean isPushed; public ButtonEditor(JCheckBox checkBox) { super(checkBox); button = new JButton(); button.setOpaque(true); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { fireEditingStopped(); } }); } public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { if (isSelected) { button.setForeground(table.getSelectionForeground()); button.setBackground(table.getSelectionBackground()); } else { button.setForeground(table.getForeground()); button.setBackground(table.getBackground()); } label = (value == null) ? "" : value.toString(); button.setText(label); isPushed = true; return button; } public Object getCellEditorValue() { if (isPushed) { JOptionPane.showMessageDialog(button, label + ": Exemplo"); } isPushed = false; return new String(label); } public boolean stopCellEditing() { isPushed = false; return super.stopCellEditing(); } protected void fireEditingStopped() { super.fireEditingStopped(); } }
Carina Marlene Posted May 23, 2012 at 02:45 PM Author Report #457634 Posted May 23, 2012 at 02:45 PM ..preciso disto tudo ?
marciofilipe Posted May 23, 2012 at 02:53 PM Report #457640 Posted May 23, 2012 at 02:53 PM (edited) ai apenas tens um exemplo de uma data-Grind com Butoes... manda me o ficheiro que eu faço te isso, marcio.filipe22@hotmail.com Edited May 23, 2012 at 02:54 PM by marciofilipe
Carina Marlene Posted May 23, 2012 at 02:55 PM Author Report #457642 Posted May 23, 2012 at 02:55 PM Eu mando, mas percebeste o que pretendia ?
marciofilipe Posted May 23, 2012 at 03:02 PM Report #457643 Posted May 23, 2012 at 03:02 PM O que Pretendes... é dentro da data-G uma sub com botoes certo? Se nao for urgente agradeço que aguardes porque de momento tenho muito trabalho e algumas coisas pendentes, assim que tocar nisso direi algo serei breve Cumprimentos
Carina Marlene Posted May 23, 2012 at 03:02 PM Author Report #457645 Posted May 23, 2012 at 03:02 PM A Subgrid ja tenho, mas eu nao preciso so de uma subgrid, visto que em vez de mostrar uma tabela na subgrid tenho que mostrar 3, caso nao consiga fazer subgrids de nivel 3 que nao consigo com este codigo, tenho que arranjar outra forma de mostrar as outras tabelas (subgrids), daí ter dito os botoes.
rumbafum Posted May 24, 2012 at 02:30 PM Report #457865 Posted May 24, 2012 at 02:30 PM Então mas o objectivo não é em Javascript? O que o marciofilipe te mostrou é Java...
Carina Marlene Posted May 25, 2012 at 08:22 AM Author Report #458031 Posted May 25, 2012 at 08:22 AM Sim é javas, mas eu acho que o template que saquei nao me permite fazer varios niveis de subgrids, esse é o problema 🙂 Obrigada Por isso é que estou arranjar outra forma de colocar botões ou assim, mas tambem nao estou a conseguir :S A única coisa que consigo fazer é isto : onSelect:function(){ alert("ola"); },
brunoais Posted May 25, 2012 at 10:40 AM Report #458058 Posted May 25, 2012 at 10:40 AM Afinal isto é java ou javascript? "[Os jovens da actual geração]não lêem porque não envolve um telecomando que dê para mirar e atirar, não falam porque a trapalhice é rainha e o calão é rei" autor: thoga31 Life is a genetically transmitted disease, induced by sex, with death rate of 100%.
rumbafum Posted May 25, 2012 at 11:09 AM Report #458065 Posted May 25, 2012 at 11:09 AM (edited) Parece-me que sempre foi Javascript, pelo menos pelo tópico inicial 🙂 daí a minha dúvida quando apareceu código Java pelo meio. ontopic: não conheço esse plugin jquery. Posso tentar dar uma olhada para ver se tem essa funcionalidade Tens aqui a página desse controlo. Pelo que vi tens lá demos com acções como editar ou apagar. De certeza que poderás adaptar ao que queres fazer: http://www.jeasyui.com/tutorial/index.php#datagrid Edited May 25, 2012 at 11:04 AM by rumbafum
Carina Marlene Posted May 25, 2012 at 11:15 AM Author Report #458067 Posted May 25, 2012 at 11:15 AM Pois sim, eu ja estive a ver essas demos todas, alias a minha ideia inicial era subgrids com 3 niveis, mas se nao as conseguir fazer poderei tentar optar ou por botoes, paneis, existem muitas formas, tenho que perceber o código, costumo sempre programar em php e aqui nao me sinto a vontade, sinto me um pouco perdida ainda :S
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now