Footable and capturing the expand row event

安稳与你 提交于 2019-12-09 23:44:49

问题


I have searched for any reasonable help on this and I keep coming back to the same comments. Namely not very good documentation.

I am about to use the jquery plugin fooTable which converts a normal html table to something pretty and usable.

It is easy to use with the following command after you have put your table on the page.

        $('.footable').footable();

However I want to capture the event when a row is expanded.

Here is an example of the table in action. I am actually using the Inspinia framework.

http://wrapbootstrap.com/preview/WB0R5L90S

You need to click on the tables / footables menu link on the left hand side.

I am not sure if this is fooTable issue/event that I should know or if this is general knowledge about capturing events using jquery that applies to lots of things.

My jquery language skills are only a few months old as I am a long time VB, MSSQL programmer who is learning something new.

Thanks to anyone who is kind enough to offer any light to a newbie!

Neil


回答1:


You can bind functions to certain footable events:

$('.footable').footable().bind({
    'footable_row_collapsed' : function(e) {
        //Your code when a row is collapsed
    },

    'footable_row_expanded' : function(e) {
        //Your code when a row is expanded                  
    },
});

Here is the documentation about footable events interception (http://fooplugins.com/footable/demos/event-interception.htm#docs).

Here is the list of footable events (http://fooplugins.com/footable/demos/events.htm#docs).




回答2:


Lack of footable documentation will end up being the end of this product.

Documentation is now listed here: https://fooplugins.github.io/FooTable/docs/jsdocs/FooTable.html

The expand event seems to be the most used. Here is an example of swapping out the detail-row using AJAX:

$(".footable").on("expand.ft.row", function (e, ft, row) {
  var EmployeeId = row.value.EmployeeId //Access data from a specific column
  var RowElement = $(row.$el) //This is the underlying DOM element for the row (<tr>...</tr>)
  if (EmployeeId) {
    $.get({
      url: "http://ajax-provider/" + EmployeeId,
      dataType: "html",
      success: function (data) {
        var DetailRow = RowElement.next(".footable-detail-row")
        DetailRow.children("td").html(data)
      }
    })
  }
}


来源:https://stackoverflow.com/questions/35807205/footable-and-capturing-the-expand-row-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!