- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2017 05:33 AM
Hi All,
I want to create two reference fields which depends on other like user and task. When i select user then in task field only tickets raised by him should be visible.
Also, providing a button "Add Row" if user clicks on this then new two fields will come and same dependency should work for this row also.
I am struggling on assigning field value dynamically to observe and get newvalue that was changed. Please help me to solve this issue.
<tr ng-repeat="rowCounter in table_data track by $index" id="tableRow_{{rowCounter.number}}">
<td ng-repeat="columnObj in rowCounter.fields">
<div class="form-group" ng-class="{'has-success' : columnObj.value != ''}">
<span ng-switch="columnObj.type">
<span ng-switch-when="reference">
<sn-record-picker field="ed_user" table="columnObj.table" display-field="columnObj.displayField" value-field="columnObj.valueField" search-fields="columnObj.searchFields" name="columnObj.name" default-query='' page-size="100" ng-if="columnObj.table == 'sys_user'" id="user" on-change="c.getLaptopDetails(table)"></sn-record-picker>
<sn-record-picker field="columnObj.value" table="columnObj.table" display-field="columnObj.displayField" value-field="columnObj.valueField" search-fields="columnObj.searchFields" name="columnObj.name" default-query="'assigned_to='+user" page-size="100" ng-if="columnObj.table != 'sys_user'"></sn-record-picker>
</span>
<span ng-switch-when="number">
<input type="number" ng-class="{'form-control-success':columnObj.value > 0}" max="{{columnObj.max}}" min="{{columnObj.min}}" class="form-control" ng-model="columnObj.value" />
</span>
<span ng-switch-when="checkbox">
<input type="checkbox" ng-class="{'form-control-success':columnObj.value > 0}" max="{{columnObj.max}}" min="{{columnObj.min}}" class="form-control checkbox" ng-model="columnObj.value" />
</span>
<span ng-switch-default="">
<input type="text" ng-class="{'form-control-success':columnObj.value != ''}" class="form-control" ng-model="columnObj.value" />
</span>
</span>
</div>
</td>
Client Controller:
$scope.ed_user ={
name: 'approver'
}
$scope.$on("field.change", function(evt, parms) {
if (parms.field.name == 'approver'){
alert(parms.newValue);
$scope.user = parms.newValue;
}
});
laurentchicoinechiragbagdaichiragb
lchicoineThanks in advance.
Regards
Swamy
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2017 04:45 PM
Not sure what you mean by a html variable, you mean a html table?
In the demo widget I made you could display it directly using the $scope.columns array.
Here is the updated HTML code for that example:
<div ng-repeat="column in columns">
<sn-record-picker field="column.field" table="'sys_user'" display-field="'name'" value-field="'sys_id'" search-fields="'name'" page-size="100"></sn-record-picker>
<sn-record-picker field="column.field2" table="'task'" display-field="'number'" value-field="'sys_id'" search-fields="'short_description'" default-query="column.queryField2" page-size="100"></sn-record-picker>
</div>
<button ng-click="addRow()">
Add row
</button>
<table border="1">
<tr>
<th>User</th>
<th>Task</th>
</tr>
<tr ng-repeat="column in columns">
<td>{{column.field.displayValue}}</td>
<td>{{column.field2.displayValue}}</td>
</tr>
</table>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2017 06:01 AM
Hi Chicoine,
It worked perfectly !!
How can i copy data selected by user to a html variable to show data in a table format?
Regards
Swamy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2017 04:45 PM
Not sure what you mean by a html variable, you mean a html table?
In the demo widget I made you could display it directly using the $scope.columns array.
Here is the updated HTML code for that example:
<div ng-repeat="column in columns">
<sn-record-picker field="column.field" table="'sys_user'" display-field="'name'" value-field="'sys_id'" search-fields="'name'" page-size="100"></sn-record-picker>
<sn-record-picker field="column.field2" table="'task'" display-field="'number'" value-field="'sys_id'" search-fields="'short_description'" default-query="column.queryField2" page-size="100"></sn-record-picker>
</div>
<button ng-click="addRow()">
Add row
</button>
<table border="1">
<tr>
<th>User</th>
<th>Task</th>
</tr>
<tr ng-repeat="column in columns">
<td>{{column.field.displayValue}}</td>
<td>{{column.field2.displayValue}}</td>
</tr>
</table>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2017 10:40 PM
Sorry for the confusion !!
User will select user and task in catalog form through this widget but when user submits form RITM wil be created. In that RITM, the selected data will not be shown as we are not storing the values selected by the user in widget.
so, i want to copy data selected by user to a html type variable and i can show it as a table in RITM. Please help me on this.
Regards
Swamy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2017 03:02 AM
I tried by creating another array, stored the values selected by user and copied to a HTML type variable. Thanks for your support !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2017 11:28 AM
So you were able to get what you wanted? Just not sure because of your reply where you say you tried, did you succeed?