volosoft / jtable

A JQuery plugin to create AJAX based CRUD tables.
http://www.jtable.org
1.1k stars 505 forks source link

Child row -> append html #613

Open trecords opened 11 years ago

trecords commented 11 years ago

Hi,

First thanks for great design, script. I want to know how can I modify script to append html codes to child objects for every main row. On click of row or button drop down child part have to be opened and it have to show custom html which would be sent by server with XHR Waiting for your help

Thanks, Turkel.

trecords commented 11 years ago

please help any little help

Xinne commented 11 years ago

Here's a little starter for you

Details: {
     title: '',
     width: '5%',
    sorting: false,
    edit: false,
     create: false,
    display: function (data) {
        //Create an icon that will be used to open child row
         var \$icon = $('<img src=\"Application/Libraries/sdmenu/collapsed.gif\" title=\"Click to show additional data\" />');
         //Open child row when user clicks the icon
         \$icon.click(function () {
            if($('#UsersAdminContainer').jtable('isChildRowOpen',\$icon.closest('tr'))){
                $('#UsersAdminContainer').jtable('closeChildRow', \$icon.closest('tr'))
            }
            else{
                /*MAKE AJAX REQUEST TO GET THE THINGS YOU WANT HERE */
                var \$childRow = $('#UsersAdminContainer').jtable('openChildRow', \$icon.closest('tr'));
                \$childRow.find('td').addClass('noscroll').html('<p>Here is my child row\'s data!</p>');
            }
          });
         //Return image to show on the person row
        return \$icon;
     }
},

have fun!