在单击 UI 网格上的链接时引导模式
Bootstrap Modal on clicking a link on UI Grid
在我的UI网格中,这是我myController.js
文件中的列定义:
{ field: 'trans_typ_dsc', headerTooltip: 'Transaction Type Description', displayName: 'Transaction Type Description', cellTemplate: '<div class="wordwrap">{{COL_FIELD}}</div>' },
{ field: 'trans_stat', displayName: 'Transaction Status' },
{ field: 'sub_trans_actn_typ', displayName: 'Sub Transaction Action Type', cellTemplate: '<div class="wordwrap">{{COL_FIELD}}</div>' , visible : false },
{ field: 'case_key', displayName: 'Case Key', visible: true, celltemplate: '<a class="text-center" ng-href="#" ng-click="grid.appScope.setAssociateCaseModal(row)">{{COL_FIELD}}</a>' },
{ field: 'approved_by', displayName: 'Approved By', visible: false }
在这里,单击case_key
链接时,应该会弹出一个 UI 引导模式。
怎么办呢?
我知道在使用按钮单击的 html 文件中,它是这样的:
<h3>Search Transaction</h3>
<div style="float: right; margin-top: -35px"><button type="button" class="btn btn-default" data-toggle="modal" data-target="#recentSearchesModal">Recent Searches</button></div>
</div>
<div class="modal fade" id="recentSearchesModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Recent Searches</h4>
</div>
<div class="modal-body">
<div class="panel panel-default">
<div class="menu_simple" ng-repeat="obj in CaseRecentSearches" style="padding:8px;">
<ul>
<li>
<a href="#" ng-click="TransactionRecentSearch(obj)" ng-model="obj"> {{obj | placeholderfunc}} </a>
</li>
</ul>
</div>
<!-- /.panel-body -->
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
但是这里的点击事件是我的控制器.js文件,那么如何打开模态?
您需要修改字段的cellTemplate
,然后调用 grid.appScope.openModal()
。 openModal
应该位于主控制器中 $scope.openModal
下。 这样做:
您的模板:
var myTemplate = "<a href='#' ng-click='grid.appScope.openModal($event, row)'>{{ row.entity.myFieldName }}</a>";
使用网格选项中的模板。
$scope.gridOptions = {
columnDefs: [{
field: 'myFieldName',
displayName: 'My Field Name',
cellTemplate: myTemplate;
}]
};
调用模态的函数:
$scope.openModal = function (e, row) {
//in here, you can access the event object and row object
var myEvent = e;
var myRow = row;
//this is how you open a modal
var modalInstance = $uibModal.open({
templateUrl: '/path/to/modalTemplate.html',
controller: MyModalCtrl,
backdrop: 'static'
//disable the keyboard
//keyboard: false,
resolve {
//pass variables to the MyModalCtrl here
event: function() { return myEvent; },
row: function() { return myRow; }
}
});
//call the modal to open, then decide what to do with the promise
modalInstance.result.then(function() {
//blah blah the user clicked okay
},function(){
//blah blah the user clicked cancel
})
}
相关文章:
- Yii2从点击链接开始加载模式
- 从内部链接进入页面时,引导模式未打开
- (阅读更多链接)到模式淡入淡出视图
- 在单击 UI 网格上的链接时引导模式
- 如何使用jQuery打开一个链接,它的末尾有一个确切的模式
- 如何在使用模式框的混合Form/HEF链接中添加其他GET参数
- 在表格最后一行(链接)中显示菜单,并在单击菜单项时显示模式窗口
- 当链接中引用视频时,是否可以在iPad上以全屏模式打开.mp4
- 在模式窗口中显示页面上单击的值(链接)以及索引值
- 基于链接的域创建模式窗口
- 通过指向引导模式的链接发布数据
- 如何将自定义隐藏/关闭链接添加到使用 lightbox2 显示的模式框
- CasperJs:单击循环中的链接以打开模式弹出窗口
- 单击链接时,无法将记录填充到引导模式
- 模式对话框内的链接不起作用
- 从链接打开窗口(模式或其他方式),并使用代码隐藏中的数据加载它
- CSS 引导关闭模式并转到链接
- 在 textAngular 编辑器中使用角度引导模式插入链接
- 带有Rails event.id的完整日历模式链接
- 我可以告诉浏览器同步始终使用一个.html文件吗?(用于html5模式链接)