Sunday, July 26, 2009

[jQuery] Re: jQuery Nesting Tables

I didn't go through your whole code, but you can always check
existence of jquery object with 'has' to check attribution, or check
for length to see if the array is not empty somethign like
$('tbody[tr:last]', '[id$=GV]).length > 0 means it exists.

On Jul 25, 11:55 pm, nullstring <jayz...@gmail.com> wrote:
> oh grace god, someone replied. thanks @FrenchiNLA
>
> here's the generated .NET html code
>
> <table class="list" cellspacing="0" border="0"
> id="ctl00_ContentPlaceHolder1_GV" style="border-collapse:collapse;">
>                 <tr>
>                         <th scope="col">&nbsp;</th><th scope="col">&nbsp;</th><th
> scope="col"><a href="javascript:__doPostBack
> ('ctl00$ContentPlaceHolder1$GV','Sort$Printer')">Printer</a></th><th
> scope="col"><a href="javascript:__doPostBack
> ('ctl00$ContentPlaceHolder1$GV','Sort$Process')">Process</a></th><th
> scope="col"><a href="javascript:__doPostBack
> ('ctl00$ContentPlaceHolder1$GV','Sort$PackageType')">PackageType</a></
> th><th scope="col"><a href="javascript:__doPostBack
> ('ctl00$ContentPlaceHolder1$GV','Sort$LeadTime')">LeadTime</a></th>
>                 </tr><tr>
>                         <td>
>                     <a
> id="ctl00_ContentPlaceHolder1_GV_ctl02_HyperLink2"
> href="PrinterProcessPackageTypeModify.aspx?
> PrinterProcessPackageTypePK=1">Edit</a>
>                 </td><td>
>                     <a
> id="ctl00_ContentPlaceHolder1_GV_ctl02_HyperLink1"
> href="PrinterProcessPackageTypeView.aspx?
> PrinterProcessPackageTypePK=1">View</a>
>                 </td><td>Alcan</td><td>Gravure</td><td>Labels</
> td><td>35</td>
>                 </tr><tr>
>                         <td>
>                     <a
> id="ctl00_ContentPlaceHolder1_GV_ctl03_HyperLink2"
> href="PrinterProcessPackageTypeModify.aspx?
> PrinterProcessPackageTypePK=2">Edit</a>
>                 </td><td>
>                     <a
> id="ctl00_ContentPlaceHolder1_GV_ctl03_HyperLink1"
> href="PrinterProcessPackageTypeView.aspx?
> PrinterProcessPackageTypePK=2">View</a>
>                 </td><td>Alcan</td><td>Gravure</td><td>Multipack
> Lidding (not foil)</td><td>35</td>
>                 </tr><tr>
>                         <td>
>                     <a
> id="ctl00_ContentPlaceHolder1_GV_ctl04_HyperLink2"
> href="PrinterProcessPackageTypeModify.aspx?
> PrinterProcessPackageTypePK=3">Edit</a>
>                 </td><td>
>                     <a
> id="ctl00_ContentPlaceHolder1_GV_ctl04_HyperLink1"
> href="PrinterProcessPackageTypeView.aspx?
> PrinterProcessPackageTypePK=3">View</a>
>                 </td><td>Emsur</td><td>Gravure</td><td>Labels</
> td><td>30</td>
>                 </tr><tr>
>                         <td colspan="6">
> <!-- here's the table I want to remove and move on top just before the
> parent table -->
>                                 <table border="0">
>                                         <tr>
>                                                 <td><span>1</span></td><td><a href="javascript:__doPostBack
> ('ctl00$ContentPlaceHolder1$GV','Page$2')">2</a></td>
>                                         </tr>
>                                 </table>
>                         </td>
>                 </tr>
>         </table>
>
> That nested table is actually the Page Links and it's not always
> there .. I mean, it only exists if GridView has something to page ..
>
> here's the idea behind these problem:
> I am using someones JS to manipulate the Table and do some column
> freezing stuff .. but everytime this page links exists, cells always
> messed up.. so my idea is to check if that page link exists, move it
> before the table(parent table) ..
>
> this code works .. but I need to check if the page links table
> exists ..
> this.before('<div><table id=\'pages\'></table></div>');
> jQuery("#ctl00_ContentPlaceHolder1_GV").find('tbody tr:last').remove
> ().appendTo($("#pages"));
>
> On Jul 26, 12:54 am, FrenchiINLA <Mamali.Sohe...@gmail.com> wrote:
>
>
>
> > Could you provide your html code generated by .net? it would help, but
> > in general rule you don't have to check existence of an element to
> > apply action to it. Jquery disregard the action if it doesn't exist.
> > For your example:
> > $('tbody[tr:last][td][table]', $(this)).remove(); will work if it can
> > find your criteria within $(this) otherwise it does nothing.
>
> > On Jul 25, 8:57 am, nullstring <jayz...@gmail.com> wrote:
>
> > > Please help?
>
> > > On Jul 25, 10:12 pm, nullstring <jayz...@gmail.com> wrote:
>
> > > > Hi,
>
> > > > In my last row (parent Table) with colspan(tr), I have another Table
> > > > (without any.attributes) which was generated by GridView, Paging
> > > > enabled and located in footer ..l
>
> > > > How do I know if that Table exists in my last row(parent Table)..
>
> > > > this code won't work ..
>
> > > > if(jQuery(this).is('table')) {
> > > >                 if(this.find('tbody tr:last td table')) {
> > > >                           /* remove paging table element */
> > > >                 }
>
> > > > }- Hide quoted text -
>
> - Show quoted text -

No comments: