Dot Net API Development Hints – Adding buttons to List page

By | November 5, 2011

Sage CRM has made the component development through dot net very much easy by providing .Net API development kit. It provides standard code templates for developer to generate the custom pages on the fly. In order to create simple new data page, summary or list page, all we need to do is just inherit the respective inbuilt classes and the entire screen is ready with all the standard buttons.
The standard entity template allows user to create entity pages like EntityDataPageNew, EntityDataPage, EntityDataPageEdit, EntityListPage, EntityDataPageDelete and EntitySearchPage. These pages serve basic idea of designing and organizing standard functionalities in .Net API.
Below is the sample code snippet used in the EntityListPage
< snippet >
using System;
using System.Collections.Generic;
using System.Text;
using Sage.CRM.WebObject;
using Sage.CRM.Wrapper;
using Sage.CRM.Data;
using Sage.CRM.Controls;
namespace Test.DataPages
{
public class DutyTypeMasterListPage : ListPage
{
public DutyTypeMasterListPage()
: base(“Project”, “ProjectList”, “ProjectFilterBox”)
{
//FilterByField = “”;
//FilterByContextId = (int)Sage.KeyList.UserId;
}
public override void BuildContents()
{
try
{
/* Add your code here */
base.BuildContents();
}
catch (Exception error)
{
this.AddError(error.Message);
}
}
}
}
< /snippet >
Above code generates the screen with:
-The list of Projects (in the current context like Company if filtered by company context)
-Filter screen to filter the project grid
-New button to create new project record (If the user has rights to create project record)
Now suppose you want to add an extra button just below the “New” button. This can be done by overriding inherited functions from base class as:
< Snippet >
public override void AddNewButton()
{
base.AddNewButton();
AddUrlButton(“Test New”, “New.gif”, UrlDotNet(“Test.dll”, “RunProjectNew”));
}
< /Snippet >
OR
< Snippet >
public override void BuildContents()
{
base.BuildContents();
AddUrlButton(“Test New”, “New.gif”, UrlDotNet(“Test.dll”, “RunProjectNew”));
}
< /Snippet >
As above, you can override other methods too, to mold and design the screen as per your requirement.
If you find this content useful, please drop us an email at crm@greytrix.com.