Separate datatable for each row in db..Net

I have long tables created with a datagrid control that goes beyond the page width. I would like to convert this to a separate table for each row or definition list, where each field name is followed by a field value.

How would I do it.

+1


source to share


2 answers


Uses jquery. If you have multiple tables, you will need to modify them to accommodate this. It is also just added to the end of the document. If you want to find it elsewhere, find the element you want to place after it and insert it into the DOM at that point.



$(document).ready(
    function() {

        var headers = $('tr:first').children();

        $('tr:not(:first)').each(

          function(i,row) {

             var cols = jQuery(row).children();

             var dl = jQuery('<dl></dl>');

             for (var i=0, len = headers.length; i < len; ++i) {
                 var dt = jQuery('<dt>');
                 dt.text( jQuery(headers[i]).text() );

                 var dd = jQuery('<dd>');
                 dd.text( jQuery(cols[i]).text() );

                 dl.append(dt).append(dd);
             }
             $('body').append(dl);
          }
        );
        $('table').remove();
    }
);

      

+2


source


Here's the link:

http://www.mail-archive.com/ flexcoders@yahoogroups.com /msg15534.html



The google terms I think you need is "invert datagrid". You will get a lot of hits.

0


source







All Articles