×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Displaying Page Nos. in Grid DTC

Displaying Page Nos. in Grid DTC

Displaying Page Nos. in Grid DTC

(OP)
Hi,

I want my page-enabled Grid DTC to show Pages like
"Page 1 of 10" rather than "1/10". What needs to be set for this to happen?

Mark
(mark@shillong.meg.nic.in)

RE: Displaying Page Nos. in Grid DTC

You will need to adjust the code in _ScriptLibrary/DATAGRID.ASP

In the Display method (function _DG_display(bReturnText)
), find this block:

  if (this.hasPageNumber)
  {
    strHTML += '<TD align=right valign=middle>';
    strHTML += '<FONT size=2><NOBR>' + String(curPage+1) + ' / ' + parseInt(nPages) + '</NOBR></FONT>';
    strHTML += '</TD>\n';
  }
  strHTML += '</TR></TABLE>\n';

Amend the bold line with the required format.

A better method would be to set a Template string, that would allow the datagrid to change formatting in a more flexible manner:
1. Add a property to the DataGrid.asp, (here called strPageFmt).

function _DataGrid(strName,objParent)
{    
  // public members
  this.id = strName;
  this.strPageFmt = "%page% of %pages%";

{1.1 OR have an array of standard formats}

2. Adjust the code as listed above to replace %page% with the String(curPage+1) value, and the %pages% with the parseInt(nPages) value.
 var strPage = "";
 strPage = this.strPageFmt.replace(/%page%/ig, String(curPage+1));
 strPage = strPage.replace(/%pages%/ig, parseInt(nPages))
 strHTML += '<FONT size=2><NOBR>' + strPage + '</NOBR></FONT>';

(or something like that! (first parameter is a regular expression, and the % may need to be escaped))

3. In your page code (thispage_onenter), set the required format string:

grdMyGrid.strPageFmt = "Now Showing <b>%page%</b> of %pages%".

VI will NOT pop-up this new property, but it should work.

NOTE: unless this format string is set on every page refresh, it will revert back to the default format that you set in step 1 above.  Remembering these settings is what the preserveState/restoreState methods are meant to achieve - so see if you can figure out the required code!

Exercise: See if you can create a list of page links too. So grid pages 1 to 10 (for example) are listed as links, rather than just the Next/Prev buttons.

www.corporateinternet.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close