how I could use Data table widget as I want to display ABC table record in it?

Virendra K
Kilo Sage

Hi All,

There is one table, ABC and want to show it in Cloned Data table widget.

where and what I need to do the changes in code? 

Please help me with sample code.

 

Thanks in advance.

Regards,

Virendra

1 ACCEPTED SOLUTION

Swathi12
Tera Expert

Hi Virendra,

 

There are 2 ways of doing it :

Way 1 :

1. Create a widget instance with class as "Instance with Table"  and save it , Then in "Table, Filter & Fields" you can add any table in Table field and add fields from table in "Fields" column. Also you can add filter conditions also in this 

2. In the "Widget" tab , add the cloned data table widget.

3. Add the above created widget instance in the desired page.

 

Way 2 :

1. Create a widget , in Data table field select "Instance with table".

2. In option schema add the table you desire for example :

[{"hint":"?view=sp","name":"link1","section":"Behavior","default_value":"?table=YOUR_TABLE_NAME&title=xyz&page=abc&view=sp&filter=YOUR_FILTER_CONDITION&enable_filter=true&show_keywords=true&o=sys_created_on&d=desc&p=1","label":"Tab 1 link","type":"string"}]

3. Call the cloned data table widget in the server script of the widget created in step1 for example dataTableWidget = $sp.getWidget('test-data-table', widgetParams);

Note : widgetParams are the ones set in step 2 and fetch it using options[links[i]] and pass it to a custom function where the data is fetched from options and set in the appropriate field.

var widgetParams = {
table: table,
o: getParameterByName(link,'o') || $sp.getValue('order_by'),
d: getParameterByName(link,'d') || $sp.getValue('order_direction'),
p: getParameterByName(link,'p') || 1,
view: view,
fields: dataFields,
page_id: getParameterByName(link,'page') || data.page_id || 'form',
show_keywords: getParameterByName(link,'show_keywords'),
show_new: getParameterByName(link,'show_new'),
filter: getParameterByName(link,'filter'),
enable_filter:getParameterByName(link,'enable_filter'),
window_size: data.window_size,
title: gs.getMessage(getParameterByName(link,'title')),
};

4. call the cloned widget in the HTML template of the widget created in STEP 1 : by using :  <sp-widget widget="dataTableWidget "></sp-widget>

 

Please do try the same and let me know in case of any queries.

 

Regards,

Swathi

View solution in original post

3 REPLIES 3

Swathi12
Tera Expert

Hi Virendra,

 

There are 2 ways of doing it :

Way 1 :

1. Create a widget instance with class as "Instance with Table"  and save it , Then in "Table, Filter & Fields" you can add any table in Table field and add fields from table in "Fields" column. Also you can add filter conditions also in this 

2. In the "Widget" tab , add the cloned data table widget.

3. Add the above created widget instance in the desired page.

 

Way 2 :

1. Create a widget , in Data table field select "Instance with table".

2. In option schema add the table you desire for example :

[{"hint":"?view=sp","name":"link1","section":"Behavior","default_value":"?table=YOUR_TABLE_NAME&title=xyz&page=abc&view=sp&filter=YOUR_FILTER_CONDITION&enable_filter=true&show_keywords=true&o=sys_created_on&d=desc&p=1","label":"Tab 1 link","type":"string"}]

3. Call the cloned data table widget in the server script of the widget created in step1 for example dataTableWidget = $sp.getWidget('test-data-table', widgetParams);

Note : widgetParams are the ones set in step 2 and fetch it using options[links[i]] and pass it to a custom function where the data is fetched from options and set in the appropriate field.

var widgetParams = {
table: table,
o: getParameterByName(link,'o') || $sp.getValue('order_by'),
d: getParameterByName(link,'d') || $sp.getValue('order_direction'),
p: getParameterByName(link,'p') || 1,
view: view,
fields: dataFields,
page_id: getParameterByName(link,'page') || data.page_id || 'form',
show_keywords: getParameterByName(link,'show_keywords'),
show_new: getParameterByName(link,'show_new'),
filter: getParameterByName(link,'filter'),
enable_filter:getParameterByName(link,'enable_filter'),
window_size: data.window_size,
title: gs.getMessage(getParameterByName(link,'title')),
};

4. call the cloned widget in the HTML template of the widget created in STEP 1 : by using :  <sp-widget widget="dataTableWidget "></sp-widget>

 

Please do try the same and let me know in case of any queries.

 

Regards,

Swathi

Thanks Swathi

srevinU
Kilo Contributor

Hello,

Is it possible to see what is the meta in the variable 'dataFields', to see how is set the field of the table ?

It seems that a mapping is done, with a 'key' and a 'Value' as a dictionary actually, but when I use it, it's not working. Could you show an exemple of the content variable ?