Dynamic columns in liferay-ui:search-container?
Asked Answered
A

1

14

I have tried the liferay-ui:search-container to fetch and display the database table records on UI in a table/grid format. By using the liferay-ui:search-container I am getting the output as shown below,

enter image description here

I am fetching the USER_ table records in the above screen shot.

Problem:

I wanted to make the grid columns dynamic like, I wanted to enable an option for end user to remove the unwanted columns and add the wanted columns in the respective grid/table.

EX:

In the above screen shot the the following columns are showing in a grid.

First Name, Last Name, Screen Name, Job Title, Organization, User Groups

Now If user wants to remove Job Title and wants to add Greetings and Mail Address columns on UI with click events with out touching/ modifying the code.

How can I implement this feature?

Note:

I need to implement this feature for custom models.

Queries:

1) Is there any api/methods to implement/enable this feature?

2) If not how can I do implement the steps? Any suggestions or steps to achieve this task?

Antonetteantoni answered 2/7, 2015 at 13:30 Comment(0)
D
12

This can be achieved by adding a configuration page to your portlet.

You can develop portlet configuration page which can have required options to be configured and save as portlet preferences.

Later on while displaying the search container you can retrieve the portlet preferences and display only those columns which were selected in the configuration form.

Here is a link on how to develop the portlet configuration using portlet preferences: Implementing Configurable Portlet Preferences

Denominationalism answered 5/7, 2015 at 16:17 Comment(5)
How to I get the list of column names in to a list? Is there any method to get the column names of any table?Antonetteantoni
check your {Entity}ModelImpl.java file for public static final Object[][] TABLE_COLUMNS = {...}; this will give you a list of columns and types. also try ModelHintsUtil.getFieldEl() , i haven't ever tired this.Denominationalism
Let's say I need to get the all columns of the USER_ table. How can I fetch all the columns of USER_ tableAntonetteantoni
Will try your suggestion alsoAntonetteantoni
I tried your suggestion and stuck with one issue, which is reported as another question in the following link, #31408711 Please provide me some suggestion/solutionAntonetteantoni

© 2022 - 2024 — McMap. All rights reserved.