Controlling List Size in ASP Pages

Hints, Tips and Tricks

Technical Hints Tips and Tricks that cover customization and development using Sage CRM. API usage and coding are covered.

Controlling List Size in ASP Pages

  • Comments 7
  • Likes

How can we override the User grid size preference for a  custom list on ASP pages?

You may have seen that there is a List block property called RowsPerScreen

ListBlock.RowsPerScreen = 5;

On the face of it, this should allow us to change the list size to what ever we need.  But according to Developers guide, "The user has a Grid Size set in their Preferences. This setting takes precedence over the RowsPerScreen setting"

In fact the RowsPerScreen as a property is only useful in the Self Service COM API

We need a way to manage the number of rows on a list in a custom ASP page to allow one screen to have List size of 15 and all others to default to whatever is set in the users preferences.

The technique we can use is to temporarily reset the users preferences so that we can control the list size.

See the code below

var intRecordId = CRM.GetContextInfo("company","comp_companyid");
var intOldGridSize = CRM.UserOption("NSet_GridSize");
CRM.UserOption("NSet_GridSize") = 10;
var myBlock = CRM.GetBlock("opportunitylist");
var Arg = "oppo_primarycompanyid="+intRecordId;
CRM.AddContent(myBlock.Execute(Arg));
Response.Write(CRM.GetPage());
CRM.UserOption("NSet_GridSize") = intOldGridSize;

I have used here the CRM.UserOption() to allow me to access the GridSize.  The property is can be read and set.

Note:  If you use this technique you will need to make sure that you reset the GridSize to the orginal value after the list has been created!

Comments
  • How do I remove paging altogether in self service, so all records are visible?

  • You can increase the RowsPerScreen property to a very large value, or perform a count of the records in the Data Set and then set the RowsPersScreen to that value.

  • I've set the RowsPerScreen property to 0, that seems to have done the trick. Thanks

  • This is what I'm looking for... Thanks.

  • Great!

  • Jeff:

    I needed to set the grid size on a panel that I added to the company summary screen.  I am not sure where I would put the following piece.

    CRM.UserOption("NSet_GridSize") = intOldGridSize;

    Would I put it in the custom content area of my companylongbox?  I tried this...but it didn't do the trick.  Any assistance would be greatly appreciated!

  • Michele

    CRM.UserOption("NSet_GridSize") = intOldGridSize;

    is code that executes server side.  This would not be recognised in the custom content because code written there is passed to the browser and executed in the client.

    How are you generating your grid to display in the Summary page?  If that is generated using an ASP to create the HTML that you then insert, you would need to control the grid size in that ASP page.