发新话题
打印

请教一些关于dbgrid的问题

请教一些关于dbgrid的问题

I have a dbrgid to show my datasets, but I want to use an extra form to edit them.

So there is one dbgrid and one button "Edit". The user should select one entry and click "edit". The new form pops up, loads the existing values and he can start working on the dataset.

So far for the theory, but:

How can I disable multiselect?

How can I find get the selected line on a dbgrid (like ItemIndex on comboboxes) for posting it do the new form?

Thanks.

TOP

to solve the problem :
1st active de onclick JavaScript Event on your DBGrid component. Then Write the folowing JS Script
复制内容到剪贴板
代码:
document.getElementById('Edit1').value=DBGrid1.getTableModel().getValue(0, DBGrid1.getFocusedRow());  
where Edit1 must be the content element for the first columnt in the row selected.
...
then you can use this value in JavaScript or PHP time.

I Hope can help you.
一個偽裝成白癡的天纔!

TOP

if you want can try write into form onload javascript event this:
复制内容到剪贴板
代码:
// Setting Columns mode
// use true to able edit or false to disable edit mode
DBGrid1_tableModel.setColumnEditable(0, true);
DBGrid1_tableModel.setColumnEditable(1, false);
DBGrid1_tableModel.setColumnEditable(2, true);
DBGrid1_tableModel.setColumnEditable(3, false);
DBGrid1_tableModel.setColumnEditable(4, true);

// Setting Position and size of grid
DBGrid1.setBackgroundColor("white");
DBGrid1.setLeft(0);
DBGrid1.setTop(0);
DBGrid1.setWidth(666); // in pixels
DBGrid1.setHeight(222);

// Setting Columns Width
DBGrid1.getTableColumnModel().setColumnWidth(0,100 );
DBGrid1.getTableColumnModel().setColumnWidth(1,200 );
DBGrid1.getTableColumnModel().setColumnWidth(2,300 );
DBGrid1.getTableColumnModel().setColumnWidth(3,400 );
DBGrid1.getTableColumnModel().setColumnWidth(4,500 );  
to get a value from the grid try write somethink like that to retrieve the values from columns 1 and 2:
复制内容到剪贴板
代码:
function DBGrid1JSRowChanged($sender, $params)
{

?>
//Add your javascript code here

document.getElementById('HiddenField1').value=DBGrid1.getTable Model().getValue(0, DBGrid1.getFocusedRow());
document.getElementById('HiddenField2').value=DBGrid1.getTable Model().getValue(1, DBGrid1.getFocusedRow());

<?php

}
一個偽裝成白癡的天纔!

TOP

Thanks a lot!

Is there an documentation out there for those JavaScript methods and properties?

TOP

这样在dbgrid我得不值,晕

TOP

triveGetElementById is case sensitive try to verify it.
一個偽裝成白癡的天纔!

TOP

发新话题