ng2-smart-table将'Add New'按钮事件绑定到外部按钮 [英] Ng2-smart-table bind 'Add New' button event to an external button

查看:193
本文介绍了ng2-smart-table将'Add New'按钮事件绑定到外部按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在为表格网格使用ng2-smart-table插件.有一个Add new按钮可将条目添加到表中.

I have been using ng2-smart-table plugin for the table grid. There is an Add new button to add entry into the table.

但是我只想从外部按钮触发'Add new'事件(可能在表的顶部,但不在表内). ng2-smart-table中已经有可用的功能与我的要求完全相反.这可以通过使用'mode:external'来实现.

But I just want to trigger the 'Add new' event from an external button (May be top of the table but not within the table). There is a feature already available in the ng2-smart-table which is completely reverse to my requirement. That can be achieved by using 'mode:external'.

当前此页面以他们的 Github页面打开.

Currently this is open with their Github page as an issue.

如果他们没有Ng2-smart-table的选项,是否有必要将事件绑定到Angular 6中的其他按钮(外部)?如果是这样,我该怎么办?

If they don't have an option with Ng2-smart-table, is there anyway to bind an event to other buttons(External) in Angular 6? If so, how can I do it?

推荐答案

您可以通过DOM对象事件触发ng2-smart-table的create事件.

You can trigger the ng2-smart-table's create event via DOM object event.

假设我的ng2-smart-table的添加按钮设置

Let's say my ng2-smart-table's add button settings

add: {
      addButtonContent : '<span class="add"><i class=""></i></span>',
      createButtonContent:'<i class="far fa-save"></i>',
      cancelButtonContent: '<i class="fas fa-times"></i>',
      confirmCreate: true,
    }

然后点击外部按钮会触发ng2-smart-table之类的添加"按钮的点击

then on click of your external button trigger the click of 'add' button in the ng2-smart-table like

onAdd(event) {
    $(".add").click();   
  }

这篇关于ng2-smart-table将'Add New'按钮事件绑定到外部按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆