- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 07:17 AM
I am trying to modify the existing set of DataTable widgets (base DataTable and via Instance) and having issues understanding how the row click operation is designed. When you click on a specific row for any given table, the record is sent to the id=form widget. I would like to be able to change this behavior, but I cannot see where the id is set or even really understand what function in the widget is managing the redirect.
go is the on-click event of the row:
$scope.go = function(table, item) {
var parms = {};
parms.table = table;
parms.sys_id = item.sys_id;
parms.record = item;
$scope.ignoreLocationChange = true;
for (var x in c.data.list) {
c.data.list[x].selected = false;
}
item.selected = true;
$scope.$emit(eventNames.click, parms);
};
I also see this code around a lot and I am do not know what it does: $location.search(search);
If somebody could help me understand how this function results in a redirect to the form widget, that would be super helpful, or even where in the DataTable widgets the form widget is being set (if it is).
Thanks!
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 10:42 AM
I found that Page_id does exist on the instance table and I needed to add it to the form in order to see it and enter information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 07:40 AM
You can find how this works on the "Data Table from Instance Definition" widget client controller. You can simply copy the same code and put in your cloned data table widget.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 09:08 AM
Thanks for the clue, I had missed that in the Instance widget, especially since the field doesn't show up in the options schema. Am I missing something on how this would be set via instance without adjusting code?
Client side:
function ($scope, spUtil, $location) {
$scope.$on('data_table.click', function(e, parms){
var p = $scope.data.page_id || 'form';
var s = {id: p, table: parms.table, sys_id: parms.sys_id, view: 'sp'};
$location.search(s);
});
}
Server:
var sp_page = $sp.getValue('sp_page');
var pageGR = new GlideRecord('sp_page');
pageGR.get(sp_page);
data.page_id = pageGR.id.getDisplayValue();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 10:42 AM
I found that Page_id does exist on the instance table and I needed to add it to the form in order to see it and enter information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2017 01:30 AM
Hi Cory,
could you please describe more in detail how you managed to make it working?
I don't know how to add the page_id to the form in order to see it and enter information.