I am trying to add more columns in data table widget which I have called from my custom widget but its not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2017 04:35 AM
I am trying to add more columns in data table widget which I have called from my custom widget but its not working.
On click of filter button it will pass the fields to data table widget which calls instance using sp widget element.
but when I pass new fields to it it shows me 'No records in' message.
Anybody please help me out of this.
I have done below:
HTML:
<div class="pull-right">
<button name="filter" ng-click="sendColumns('number','priority','short_description','u_query');">Filter</button>
</div>
<div class=" col-md-9 ">
<uib-tabset active="activeJustified" type="pills">
<uib-tab index="0" ng-if="data.newWorkPackage==false">
<uib-tab-heading class="tab-title">Work Package <!--span class="badge">{{data.item_count}}</span--></uib-tab-heading>
<div class="panel panel-default" >
<widget id="widget-form" options='{"table": data.table,"sys_id":"-1"}'></widget>
</div>
</uib-tab>
<uib-tab index="1" ng-if="data.AllWorkPackage==false">
<uib-tab-heading class="tab-title">View All Work Packages <!--span class="badge">{{data.item_count}}</span--></uib-tab-heading>
<div class="panel panel-default" >
<div class="myhelp-data-table-instance">
<div class="alert alert-info" ng-show="loadingData">
<fa name="spinner" spin="true"></fa> ${Loading data}...
</div>
<div class="alert alert-danger" ng-if="data.invalid_table">
${Table not defined} '{{data.table_label}}'
</div>
<div ng-show="!loadingData">
<sp-widget widget="data.dataTableWidget"></sp-widget>
</div>
</div>
</div>
</uib-tab>
</uib-tabset>
</div>
</div>
Client:
$scope.sendColumns = function(number,priority,short_description,description)
{
$scope.data.val = number+','+ priority+','+short_description+','+description;
$scope.server.update();
}
Server:
data.p = 1;
data.defaultTable="u_work_package_main";
data.defaultFilter="active=true";
data.order="100";
data.defaultView="";
data.breadcrumb = true;
data.keywords = false;
data.newbtn=false;
data.tabbedRecordAvailable = true;
if(input.val)
{
gs.addInfoMessage('Yes I am'+input.val);
data.p = 1;
data.defaultTable="u_work_package_main";
data.defaultFilter="active=true";
data.order="100";
data.defaultView="";
data.breadcrumb = true;
data.keywords = false;
data.newbtn=false;
data.tabbedRecordAvailable = true;
data.fields=input.val;
//$sp.getListColumns(data.table, data.view);
data.widgetParams = {
p : data.p,
table:data.defaultTable,
filter: data.defaultFilter,
o: 'sys_created_on',
fields:data.fields ,
d: data.order,
view: data.defaultView, //view: 'ess',
window_size: data.window_size,
title: data.defaultTable,
show_breadcrumbs: data.breadcrumb,
show_keywords: data.keywords,
show_new: data.newbtn
};
data.dataTableWidget = $sp.getWidget('widget-data-table', data.widgetParams);
}
data.fields = 'number,priority,state,assigned_to,short_description'; //$sp.getListColumns(data.table, data.view);
data.widgetParams = {
p : data.p,
table:data.defaultTable,
filter: data.defaultFilter,
o: 'sys_created_on',
fields:data.fields,
d: data.order,
view: data.defaultView, //view: 'ess',
window_size: data.window_size,
title: data.defaultTable,
show_breadcrumbs: data.breadcrumb,
show_keywords: data.keywords,
show_new: data.newbtn
};
data.dataTableWidget = $sp.getWidget('widget-data-table', data.widgetParams);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2018 05:53 AM
Hi llemirande,
Are you able to share how you are changing the filter?
Also for clarification by "filter" do you mean the queries being set to determine which records should display in the list?
I modified the last code I posted to dynamically and randomly change the filter. Here is an example where I randomly change the columns and filters via a button. Note: It's just random so sometimes it doesn't change because it randomly chose the same data. Hopefully the video sticks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2018 08:03 AM
ChrisB,
Thank you for the reply! I figured out how to change the filter using your reply. What I am stuck on now is maintaining the "Keyword Search" when I apply the filter dynamically.
// Event caught based on filter selected in the Idea Sidebar widget
$scope.$on('ideaPortal.applyFilter', function(event, data) {
console.log('Event caught type is: ' + data);
var params = $scope.data.widgetParams;
params.filter = data;
params.show_keywords = true;
spUtil.get('widget-data-table', params).then(function(response){
$scope.data.dataTableWidget = response;
})
});
Above is what I am using to do so, I am confused why 'params.show_keywords=true;' does not keep the search option when I swap filter.
Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2018 08:52 AM
Ah. It's not keeping the show_keywords because the widget is only setup to take options.show_keywords and not input.show_keywords.
You have to keep in mind that when using spUtil.get('widget-id', options) to embed a widget the options that are applied to it are actually placed on the input object since it's client side and not the options object.
So to control that you can apply it to the options object once you get the response but before you assign it to your variable holding the widget.
For example try:
spUtil.get('widget-data-table', params).then(function(response){
response.options.show_keywords = true;
$scope.data.dataTableWidget = response;
})
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2018 09:02 AM
That seems to keep the search bar, but the function of the search seems to break when I apply it this way? I get completely different results compared to on load. Why would that be?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2018 09:12 AM
Scratch that, it works at expected!
Thank you