I have a abstract table (table or treetable view does not matter) view which have lots of column. But not all columns are visible at the same time. Now what i want to do, when i export the table contents to pdf/excel read each row data but actually in javafx we can not get row and cell data directly. For this we must use row/cell factory. But in this case this factory is called only when we add data to the table. I can read table data model for each row but in this case i must chek which columns are visible and invisible and which data model used always, and call the required method of the data model. Doing this required lots of code lines because as mentioned i have lots of column and nested column and also different data models. So during exporting to check all of these required lots of code line. But if i can read the row and cells of row i do't need to check invisible row and data model. Just read current row and data of cell. So my question is how can i solve this issued? Do you have any suggestion?
Any suggestion?
finally I solved this problem. Thanks for java documentation. I post some code snippet so who needs can use. For reading cell value on (row,column) intersection on TreeTableView
int rowIndex = treeTableView.getRow(treeRowItem);
for(int i=0;i<treeTable.getColumns();i++){
TreeTableColumn ttc = treeTable.getColumns().get(i);
String value = ttc.getCellData(rowIndex).toString();
}
you can also use the same logic on TableView
Related
I want to save a specific value that is on a specific row and column. How I can do this? I already search, but I didn't find anything
One doesn't save a value from the grid but rather from the underlying dataset. The following is for Delphi, but I understand that Lazarus is near enough the same. Let's say that the grid is displaying data from a query qTest that has fields id, surname, forename, date of birth (DOB). In Delphi, one can automatically have variables created with names qTestID, qTestSurname, etc. Another way of referring to the variables is by use of the 'fieldbyname' syntax - qTest.fieldbyname ('surname').asstring.
Write a dblClick handler for the grid: when one gets to the row that holds the required data, perform a double click. In the handler, the fields of the row will now be available as qTestID.asinteger, qTestSurname.asstring, etc.
I'm using Handsontable and was able to fill a data grid with 16 rows and 9 columns retrieved from a database. Each cell represents a value from a table with a many to many relation. When saving the data-grid, an array is passed to view. I want to clearly identify each cell with the id provided from the table. Is this possible? I read about the setCellMeta(), but don't know how to apply this...
What you can do is iterate all cells and set metadata for each cell (rows and columns) with the value you need.
myhot.setCellMeta(0,0,'Id',1);// where parameters are: row, col,propertyName, value.
later you can do the following to read :
myhot.getCellMeta(0,0) // rown, col
I hope it helps
How do I get the search/filter to work per column?
I am making small steps in building, and constantly adding to my data table, which is pretty dynamic at this stage. It basically builds a datatable based on the dat that is fed into it. I have now added the footer to act as a search/filter, but unfortunately this is where I have become stuck. I cannot get the filer part to work. Advice greatly appreciated.
here is my sample data tables that I am working on http://live.datatables.net/qociwesi/2/edit
It basically has dTableControl object that builds by table.
To build my table I need to call loadDataFromSocket which does the following:
//then I have this function for loading my data and creating my tables
//file is an array of objects
//formatFunc is a function that formats the data in the data table, and is stored in options for passing to the dTableControl for formatting the datatable - not using this in this example
//ch gets the keys from file[0] which will be the channel headers
//then I add the headers
//then I add the footers
//then I create the table
//then i build the rows using the correct values from file
//then I draw and this then draws all the row that were built
//now the tricky part of applying the search to each columns
So i have got this far but the search per column is not working. How do I get the search/filter to wrok per column?
Note this is a very basic working example that I have been working off: http://jsfiddle.net/HattrickNZ/t12w3a65/
You should use t1.oTable to access DataTables API, see updated example for demonstration.
Please compare your code with jsFiddle in your question, notice its simplicity and consider rewriting your code.
I'm using ClosedXML it has a method called InsertData to insert a DataTable like this:
var rangeWithData = worksheet.Cell(row, cell).InsertData(dataTable.AsEnumerable());
as mentioned here: ClosedXML Inserting data
In my xml I have one merged column and it causes to miss one column from the data table.
Is there a way to handle it and still use the InsertData method or should I loop over the data table...?
You can use InsertData if you know beforehand which cells are merged and prepare the DataTable accordingly.
If you don't know that you have to use loops and move the data when you get to the merged cells.
I have a tableview with one textboxcolumn and 7 checkbox columns.
This table will eventually be filled with data, and at some later point i have to remove one of the columns somewhere in the middle. What happens with the array associated with the table? How should i proprtly handle this? How would you do it? Please be clear in your answer since i am a beginner!
Have you learned how to provide data to the table view? I suggest getting that working before you try to solve this problem.
There are two ways to get data to the table view: a table view data source and Cocoa Bindings.
If you use a data source, you'll need to write -tableView:objectValueForTableColumn:row: so that it works correctly before or after the column is removed. One way to do this is to base that code on the column's identifier instead of its index. The identifier is a value you set on the column in your nib (look for Identifier). This is the same technique you can use to provide the correct data to reordered columns.
NSString *identifier = [column identifier];
if ([identifier isEqualToString:#"firstField"]) {
return ...
} else if ([identifier isEqualToString:#"secondField"]) {
return ...
}
If you use Cocoa Bindings, you can just remove a column and the other columns will keep working.
If you're using an array or an array controller, in neither case will anything automatically happen to the array when you remove a column.