I was using setColumnHeader(Object, String) to set a simple string as a column header. I want to create a complex header. I would like to know if there is any way to build a similar table as shown in the below figure in Vaadin 7. http://i.stack.imgur.com/u5dIw.gif
Now it is possible using Grid:
// Group headers by joining the cells
HeaderRow groupingHeader = grid.prependHeaderRow();
HeaderCell namesCell = groupingHeader.join(
groupingHeader.getCell("firstname"),
groupingHeader.getCell("lastname"));
HeaderCell yearsCell = groupingHeader.join(
groupingHeader.getCell("born"),
groupingHeader.getCell("died"),
groupingHeader.getCell("lived"));
This example is taken from Vaadin Book. Just to show that new Vaadin 7.5 (and above) can build table with complex header (joined columns). Another good resource is in Vaadin Wiki.
As you notice such grouping is also possible for footer row.
Not at the moment.
It is scheduled for vaadin 7.4, which is currently in alpha stage.
Related
I'm creating a zk component for mount easy grid from view database. One of its powerful features is the automatic generation of filters by column. These filters appear automatically on the top column inside the auxheader tag and all are generated programmatically in java with the column info. Example of database view TIMESTAMP column (sorry not css right now):
https://prnt.sc/ZK9nMws2l68p
My problem now is that I don't know how to bind these datebox generated programmatically in java with the view for recovering the filter values.
I was searching inside the zkoss wiki and only found this:
create data binding programmatically,
where you can find how bind zk components of the zul, or how bind components generated programatically if the parent has an item render option.
But i need generate N datebox, numberbox, textbox depending on the number and type of the columns and recover the values of it.
Anyone knows how do it?
The component has a loot of code and scrap, but more or less the idea is:
https://pastebin.com/Q5VX472L
cols.setParent(gridDatatable);
// create filters inside AuxHeads
Auxhead auxhead1 = new Auxhead();
// create a line with the same number of AuxHeaders as Columns we have
for (int indexColumn = 0; indexColumn < columnsList
.size(); indexColumn++) {
if (columnsList.get(indexColumn).getVisible()) {
// i have definned the diferent Auxheader with a patron factory
Auxheader auxheader = gridDatatableFilterFactory.generateFilter(
columnsList.get(indexColumn).getTerms().getType(),
columnsList.get(indexColumn).getTerms().getKey());
auxheader.setParent(auxhead1);
}
}
// set the Auxhead line between col names and rows
auxhead1.setParent(gridDatatable);
// we add the rowrender for print the rows
gridDatatable.setRowRenderer(
new DatatableRowRender(columnsList, gridDatatableCellFactory));
search();
Thank you in advance, regards.
I have working Spring REST app with client side pagination, default by DataTables and everything works. Now i need to change it to server-side pagination i have problem, because have no idea how to get information from DataTables what page number client want to see. I can't find anything usefull in DT manual.
When you say Datatable I assume you are talking about DataTables jQuery plugin.
To activate serverside pagination you need to pass
"serverSide": true,
like this:
$('#example').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "/your_url"
});
Doing the above will activate your server-side pagination. But you need to do few changes on the server-side too. Let's see them step by step.
1. What happens when you mark serverSide as true
DataTables plugin adds custom parameters to the AJAX call with information like
order: asc
start: 20
length: 10
// and many more.
You can inspect this demo link and see the parameters passed in request when you click the next page button.
2. Similarly, DataTables plugin expects some fields in response in order to preserve pagination logic.
"draw": 3, // unique ID
"recordsTotal": 57, // total number of records
"recordsFiltered": 57 // total number of filtered records
You can inspect this demo link and see response data this time.
3. Now changes are on serverside in your API
You need to add these parameters as queryParam for GET and attr in POST call in your controller API:
order: asc
start: 20
length: 10
4. Service Layer Changes - DB query
In-Service Layer where you get details from a database.
You need to get the total number of records and in search query pass a LIMIT clause LIMIT 10, 10 in case of MySQL.
E.g.:
SELECT * FROM User LIMIT 20,10;
Use start and length to calculate the next set of records.
It can be trickier but if you understand and implement properly it's fun.
Read more in detail here which also contains code and live demo.
Please see the sample about DataTables server-side processing:
https://datatables.net/examples/server_side/simple.html
After change page, you can capture the request to server as following format:
https://.../server_processing.php?draw=3&columns...&order=0&dir=asc&start=20&length=10&search%5Bvalue%5D=&search%5Bregex%5D=false&_=1534436781912
That means DataTable requests page number 3 (draw=3), order by first column ascending, ....
At server side (REST), you can get page number by (for example) request.getParameter("draw")
I had created one search page using custom viewcriteria with five parameters.In my search page working perfect.I have one doubt,we are entering the some parameters in the search page to get the details from one table, Here i need that values which we are entered in that boxes for using that values into a one java class.
How get those values?
Maybe ,This link can help you.you should glance
http://www.awasthiashish.com/2013/07/implementing-custom-search-form-in-adf.html
You can read the search value from a custom BC method (either on AM or VO impl level):
ViewCriteriaImpl applyVC =
(ViewCriteriaImpl)myViewObject.getViewCriteria("MyViewCriteriaName")
while(applyVC.hasNext) { Row vcrow = applyVC.next(); .... }
E.g.
Here is a link http://en.wikipedia.org/wiki/Brad_Pitt_filmography
which lists all the films of brad Pitt in table format.
I want grab the table content.
Query-> http://en.wikipedia.org/w/api.php?action=query&titles=Brad_Pitt_filmography&
what other parameters will come in the query ?
How can I store it in MySQL Database using Java
use "action=parse":
http://en.wikipedia.org/w/api.php?action=parse&format=xml&prop=text&page=Brad_Pitt_filmography§ion=1&contentformat=text/plain
you can change "prop" to text(html) or wikitext. for more info please check this:
http://en.wikipedia.org/w/api.php?action=help&modules=parse
I'm trying to migrate from MySQL database to ElasticSearch so I can use the full-text search technique using BM25 similarity over each fields. I'm using JAVA to fetch entries from MySQL and add them into the ElasticSearch index.
I'm building my index using the JAVA index API, but I can't figure out a way to set the BM25 similarity over my fields.
I consider a table products table from MySQL and dev as an index with products as it's index type.
The original table products contains the following fields :
id
title
description
You can find the code on my Github, If you'd like to take a look.
It's forked project that I've configured with Maven integration.
Any suggestion and any help is welcome, Thanks!
I found the answer for my question.
Here is the code :
Settings settings = ImmutableSettings
.settingsBuilder()
.put("cluster.name", "es_cluster_name"))
// Define similarity module settings
.put("similarity.custom.type", "BM25")
.put("similarity.custom.k1", 2.0f)
.put("similarity.custom.b", 1.5f)
.build();
Client client = new TransportClient(settings);
It seems that you can define the similarity modules you wish to use in the Settings before you instantiate your Client.
Here is the list of similarity modules that are supported by elasticsearch for the moment :
default, BM25, DFR, IB, LMDirichlet and LMJelinekMercer. You can specify which one you want to use in the Settings like below :
.put("similarity.custom.type", "..." )
Each similarity has its own parameters which you would want to configure as well in order to use it properly.
Note: Code tested on elasticsearch 1.1.0.