jump to navigation

Datagrid Fun… April 16, 2009

Posted by richeaton in Code Snippets, SalesLogix General.
Tags:
trackback

One of the very common customizations in the SalesLogix LAN client has been to place two data grids side by side and have the selection in one grid control the data that is viewed in the other. When I first thought of trying to move this type of functionality to the web client I was a little nervous. I checked around and while it seemed possible it wasn’t something that was being done frequently on the web. The example I’ll show here is a basic one that can give you a good jumping platform.

How I accomplished this:

  • I was being forced by Application Architect to bind my data grid to a data source — I was able to resolve this by creating a business rule that returned me nothing and used that in my getby method for a data source. Here is a snap shot of that code:

public static void GetEmptyRecordSetStep( IAccount account, out System.Collections.Generic.IList<Sage.Entity.Interfaces.IAccount> result)
{
result = new System.Collections.Generic.List<IAccount>();
}

I have to admit I found this tip on the SLX Developer web site. This allows the data grid to load, we will be changing the data source on the selection from the other grid so I would make sure in your grid creation you add an empty row statement that helps out the users.

  • The next step was to add a “Select Row” column to my columns in the first data grid.  ** Major tip here is to ensure that you add DataKeyNames to this grid for the fields you’d like to be selected. You’ll find this property just below the data source. **
  • In the first datagrid select the OnRowSelectedAction, followed by C# Snippet and when the editor opens you can add the following code..

int rowindex = FirstDataGrid.SelectedIndex;
foreach (DictionaryEntry val in FirstDataGrid.DataKeys[rowindex].Values)
{
if (val.Key.ToString() == “Id”)
{
Sage.Platform.Repository.IRepository<Sage.Entity.Interfaces.IYOURENTITYs> acct =                                           Sage.Platform.EntityFactory.GetRepository<Sage.Entity.Interfaces.IYOURENTITY>();
Sage.Platform.Repository.IQueryable qry = (Sage.Platform.Repository.IQueryable)acct;
Sage.Platform.Repository.IExpressionFactory ef = qry.GetExpressionFactory();

Sage.Platform.Repository.ICriteria criteria = qry.CreateCriteria();
criteria.Add(ef.Eq(“Accountid”, val.Value.ToString() ));

SecondDataGrid.DataSource = (criteria.List<Sage.Entity.Interfaces.IYOURENTITY>());
SecondDataGrid.DataBind();
}
}

This send the entity requested via the section criteria to the data grid and binds it. I have found that since this is on a quick form inside of AA you really don’t need to wrap the data grids in an AJAX update panel, if you were to move this to a custom form then I would suggest wrapping the data grids each in their own panel which could be updated with a simple, UpdatePanelID.Update.

I hope this helps clear some of the confusion, it really didn’t turn out to be that hard once I had the things I needed.

Good luck and shortly I’ll have a few more examples of some real world things…

Comments»

1. SalesLogix Training Blog » Blog Archive » How do I add two datagrids to a form that are correlated – dependent datagrids - September 30, 2009

[...] asked and I thought it was a neat customization. It turns out it has already been documented here, but that didn’t exactly work without modifications for [...]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.