I am new to PowerBuilder and I need to add a new column to a DataObject. The DataObject has several fields which retrieves data using select statement. So if I add a column in the select statement I get another field with a name compute_0041 along with the added column field. When i try to remove the compute_0041 field I cannot see any value in the field representing a new column. How do I remove the compute_0041 that gets automatically added?
Thanks
In Datawindow if you accidentally put a 0 or '' in one of the rows in the tab called Computed Columns then these columns may come in. Of course, you can also have a computed column yourself by specifying it there but since it seems you think you didnt do anything and it came up on its own it appears to be an accidental issue.
You can of course check for it by going to the SQL mode and checking for it there. Also, the last tab in the design view it shows the complete generated SQL where you can easily see a select column that is not chosen by you.
Hope the above will aid you to identify the issue. Please let me know if you still have the issue.
Related
How do people tend to let users re-order the grid columns and save that ordering for later?
The only way I can think of to do it, at least in Vaadin 7, is:
Listen for column re-ordering via addColumnReorderListener(…)
When re-order triggered, if user initiated, get columns from getColumns() and save to DB with any identifying information
When pull Grid back up, read grid ordering from DB and apply the same order with setColumnOrder(columns)
So is there a better way to do this? I just checked the Directory, could not find anything obvious to make this easier. Just looking for how others have addressed this user requirement. If Vaadin 14 already supports such actions a little easier, that would be good to know as well, as it might give me some ideas on how to get that ability short term before I can upgrade to Vaadin 14.
For a more customizable grid you can (in addition to what you've already done) add a button that opens a dialog that lists all possible columnnames, together with a checkbox.
Unchecking the checkbox removes the column, checking the checkbox adds the column.
Even more comfortable is when the dialog lists all available columns in a Grid with draggable rows and editable checkboxes, so that the user can show, hide and sort all columns in one place. After that you have to reorder all columns by calling grid.setColumnOrder.
Just so people know how I solved this issue, based on the comments:
When load data into Grid, first check database for columns of this Grid/user combination. If find such a column order, call setColumnOrder(userColumns).
Added 2 buttons to top, one to save column order, one to reset it.
"Save" button only enabled after moving at least one column.
"Reset" button only enabled if at least one column was moved. One column was moved either because of the DB, or because user JUST moved a column.
On save, save to DB. On reset, clear from DB, and reset Grid to original column order.
We chose not to save the column order each time they changed the order, directly in the addColumnReorderListener, because we realized sometimes users might move columns around temporarily, and one really want to save that column order for the future. That said, the saving inside the addColumnReorderListener worked well.
We don't currently need to save the column sizes, as suggested by #Simon Martinelli, but we are keeping it as an idea for the future. I fully expect it would work.
So ATM the user can download an xlsx document, and add new records to it, upload it to the application which updates the DB(with the new records)
I would like to put an option in the excel doc. like a check box (at the beginning of each row) or something like this which, if selected when the doc is uploaded again, it will delete that record from the DB.
I know the logic and how to delete the record but im not sure how to include something like a check box and relate it to each seperate row?
Any one have any ideas?
thank ye
You can use Checkboxes, although you would need to use an "xlsm" (macro-enabled workbook) to insert them. (you could do it without vba but manually inserting checkboxes and configuring them isnt going to be much fun)
Checkboxes can be "linked" to a cell in your workbook. You'd need to add a Checkbox to each line, and set the linked cell to another cell on that row (preferably all the same column).
You could also make it a lot simpler by doing away with the checkbox and just having a column that you set to true (or any non-empty value) and have your application interpret that to delete the records.
Both methods require you to have an extra column.
Any method will require either an extra column or another sheet with a single column to track the state of each line.
I want to autofill a formula to a bunch of fields in one column. I can do that by filling two fields manually then select them and drag down.
I want column B's cells to be =D1*A1 , =D1*A2,... Note D1 should not change.
When I drag the fields down or use (Edit > Fill...) it changes D1 to D2, D3,... How can I keep one field fixed for autofill?
Holding ctrl button down does not help.
Any idea?
Make your "master" formula =D$1*A1. That flags the 1 in the D$1 part as being constant. You could also make the D part constant with =$D$1*A1, but since you stated this is a single column, it shouldn't matter in this case.
Note that this also works for Microsoft Excel, and I think that it's been a common feature of almost all spreadsheets since way back to supercalc on HDOS.
I just found another way (that is not easier than twalberg's, but worth mentioning)...
You can define a name (Insert > Names... Define). Select a field and give it a name. Then the name in your formulas.
as a follow up question to my previous one. I can edit the DBMemo's now.
However they always seem to have the values from the very first row in the table.
I've done a DBMemo1.Text = ''
I've done a locate on the DataSet underneath to see if it would clear it. but no.
What do I need to do to have that empty and type something in to insert it?
Like any other data-aware control, the memo is bound to the values from the current row in the table. Try putting a TDBNavigator and a TDBGrid on your form so you can play around with the current record and see what's going on. If you want to create an empty row to insert into it, you need to call Insert or Append on the dataset, or click the + symbol on the TDBNavigator. This creates a new, blank row in the dataset and sets it to the current row.
You probably need to add a new row to the dataset.
DataSet.Append;
I saw your last question and I believe the following tutorial will help you:
http://delphi.about.com/od/database/a/databasecourse_2.htm
To clear the text from DBMemo you should either Insert, Append or Delete+Insert/Append on your data set. Mason explained you very well that you need to have a 'navigator' for your data set. Follow the examples provided here:
http://delphi.about.com/od/database/ss/dbcourse_browse.htm
Best regards,
Radu
So I'm messing around with a new project in Delphi 2009 and the default components that can be dropped onto a form for accessing data consist of a SQLConnection, DataSource and SQLQuery. If I add a simple select to the query component, say:
select name from customers
and then drop a DBComboBox on the form and link it up with the DataSource I get a single record in the combo box. After using Google for half and hour to figure out what I was doing wrong it looks like you have to manually add some code to your project which loops through the dataset and adds all the records to the drop down box. Something like:
while not SQLQuery.eof do
begin
DBComboBox.items.add(SQLQuery.fieldbyname('name').asstring);
SQLQuery.next;
end;
And that actually sort of works, but then you get a list in the drop down which you can't actually select anything from. Regardless of the result though I'm wondering why would you even use a DBComboBox if you have to manually add the result of your query to it? Seems to me that if it doesn't automatically populate the db combo box with the result of the query then we might as well be using a non-data-aware component like tcombobox.
I guess what I'm asking is why does it work this way? Isn't the purpose of data aware drag-and-drop controls to minimize the amount of actual written code and speed development? Is there a method that I'm missing that is supposed to make this easier?
A TDBComboBox doesn't get its list of values from the database; it gets its current value from the database. Link it to a field in your dataset, and when you change the active record, the combo box's current value will change. Change the combo box's current value, and the corresponding field's value will change.
If you want to get the list of values from the database as well, then use a TDBLookupComboBox.
This is all covered in the help:
Using TDBListBox and TDBComboBox
Displaying and Editing Data in Lookup List and Combo Boxes
Defining a Lookup List Column
I think you want the TDBLookupComboBox because that allows you to lookup from a list of items where the list comes from a dataset.
In the TDBComboBox, the list is just a TStrings manually filled with data.
--jeroen
DbCombox is a dbaware version of the standard combobox component.