lookups change in 2.6
Moderator: Phil Barton
lookups change in 2.6
1. table = lookups.GetTable(TableName, spec) is not working in 2.6 and was in 2.5. The error received is 'GetTable' is not a member of softpro.ordertracking.client.lookups.
2. Dim value As SoftPro.OrderTracking.Common.LookupValue is no longer a defined value in 2.6
I think a bunch of changes to related to lookups. Please help. I can't stand having to re-code for every upgrade.
2. Dim value As SoftPro.OrderTracking.Common.LookupValue is no longer a defined value in 2.6
I think a bunch of changes to related to lookups. Please help. I can't stand having to re-code for every upgrade.
Re: lookups change in 2.6
Lookups went through a major overhaul in 2.6, from a 2-tier to a 3-tier service with much improved performance metrics. The changes include a remodeled Lookups Manager and a redefined Lookups API.
Unfortunately, third party code written against the 2.5 API needs to be updated to use the new lookup API. The good news is that the new 3-tier lookup infrastructure is robust, performant and flexible, and the new API is no longer expected to change in a major way (though I cannot rule out possible tweaks, hopefully non-breaking to you).
The SDK documentation has been updated to reflect the new API usage, please take a look at the HowTos --> Using the API --> Using the Lookup Tables API section.
Lookup interfaces are now in the SoftPro.OrderTracking.Client assembly. The short answers to your questions are the following:
Let us know if you run into problems.
Unfortunately, third party code written against the 2.5 API needs to be updated to use the new lookup API. The good news is that the new 3-tier lookup infrastructure is robust, performant and flexible, and the new API is no longer expected to change in a major way (though I cannot rule out possible tweaks, hopefully non-breaking to you).
The SDK documentation has been updated to reflect the new API usage, please take a look at the HowTos --> Using the API --> Using the Lookup Tables API section.
Lookup interfaces are now in the SoftPro.OrderTracking.Client assembly. The short answers to your questions are the following:
1. GetTable() is now replaced with QueryTable(), and the table name is now specified in the spec argument. Here is an example:czentman wrote:1. table = lookups.GetTable(TableName, spec) is not working in 2.6 and was in 2.5. The error received is 'GetTable' is not a member of softpro.ordertracking.client.lookups.
Code: Select all
Lookups lookupService = server.GetService<Lookups>();
LookupQuerySpec spec = new LookupQuerySpec();
spec.Table = "MyTableName";
spec.SchemaOnly = false;
ILookupTable table = lookupService.QueryTable(spec);
2. LookupValue has been replaced with ILookupValue, which you can use like this:czentman wrote:2. Dim value As SoftPro.OrderTracking.Common.LookupValue is no longer a defined value in 2.6
Code: Select all
ILookupRow newRow = table.NewRow();
ILookupValue newName = newRow.NewValue(false, "Joe");
Re: lookups change in 2.6
thanks. that was pretty helpful. I still don't know a way of deleting a row from the ilookuptable/ilookuprow types. Something like ilookuptable(0).delete or ilookuprow.delete. I looked in the sdk doc and didn't find it helpful. Altogether, I can't seem to find any coding snippet examples in the sdk documentation.
Re: lookups change in 2.6
Try something like this:
If you look at the interface, ILookupTable you will find that Rows is defined as a ILookupRowCollection, which is derived from ICollection, which contains the Remove method.
Code: Select all
ILookupTable lookupTable = lookupSvc.QueryTable(spec);
if (lookupTable != null)
{
ILookupRowCollection foundRows = lookupTable.Rows;
foreach (ILookupRow row in foundRows)
{
lookupTable.Rows.Remove(row);
}
lookupSvc.ApplyChanges(lookupTable);
}
Robert
Re: lookups change in 2.6
Thanks. I thought I got the code basicly "converted" but my gridview is not filling up. I just use the code to "DataGridView1.DataSource = table". Can I make a datasource for a gridview be a ilookuptable datatype? Do I have to do it another round about way?
Re: lookups change in 2.6
Sorry, I don't use bound controls, so I don't know much about them.
Robert
Re: lookups change in 2.6
Try binding the Rows property to your grid. You may need to write your own customized binding source, with the lookup table as data source and the "Rows" property as data member, depending on what functionality you want your grid to provide.
Re: lookups change in 2.6
That seemed to help. I'm still having a hard time viewing the data in the gridview but I can see the data there. Now I'm having trouble doing the spec.filter - I don't think it's working. What's the correct syntax for the filter. Is it better to use the spec.search - I see there's a search event on the lookupqueryspec object that I'm using.
Re: lookups change in 2.6
You may use the Search property on the LookupQuerySpec object if you wish, by passing in a search string (works like Google search).
Or you may be more specific by using the Filter property to get a filtered set of rows, as such (this is from the Using the Lookup Tables API in the SDK Documentation):
SQL wildcard convention is used to achieve "starts with" and "contains" functionality.
To filter on the key column, use the special name "{KEY}", as shown below:
Please refer to the SDK documentation for more details, and let us know if there is any specific query you are trying to achieve. I hope this helps.
Or you may be more specific by using the Filter property to get a filtered set of rows, as such (this is from the Using the Lookup Tables API in the SDK Documentation):
Code: Select all
LookupQuerySpec spec = new LookupQuerySpec();
spec.Table = "MyTableName";
spec.Filter = "[Name] LIKE @val"; //
spec.FilterParameters.Add("val", "c%");
ILookupTable table = lookupService.QueryTable(spec);
To filter on the key column, use the special name "{KEY}", as shown below:
Code: Select all
spec.Filter = "[{KEY}] LIKE @val";
Re: lookups change in 2.6
That was helpful. Actually, I looked up lookupqueryspec in the sdk doc and I didn't one example of syntax like you just gave in a jiffy. Also, I'm now having a hard time converting to a cell-text to view the data on the screen. I know the data is there because I already had a routine that when you click on the cell it puts all the data into textboxes and it uses a trycast for each textbox. But I want to do that trycast on rowbound but I don't see a rowbound function or something like that.