By Philipp Guntermann - 3/9/2009
hi,i got two issues with the browse dialog: 1) how do i set it up, so that instead of populating the business object with the selected search result, it would only navigate to the selected search result instead ? 2) the waitwindow message appearing while it performs the search is not localized. (appears in english) thanks.
|
By Trent L. Taylor - 3/10/2009
how do i set it up, so that instead of populating the business object with the selected search result, it would only navigate to the selected search result instead ? I am not sure that I follow you on this. It actually does navigate to the selected record. If you are wanting to update a BO other than the BusinessObjectToPopulate, then create a second BO on the for and set that to the BusinessObjectToPopulate, then in the BrowseDialogClosing (or where ever meets your needs) navigate the record on the other BO to which you are wanting to update. 2) the waitwindow message appearing while it performs the search is not localized. (appears in english) Hmmm...OK, thanks. I will look into this.
|
By Philipp Guntermann - 3/10/2009
Trent L. Taylor (03/10/2009)
I am not sure that I follow you on this. It actually does navigate to the selected record. It fills the BO with the selected record, and then navigates there too. instead it should: leave the BO as it is (keep all records as they are) and ONLY navigate to the selected record. dont re-populate.
|
By Ivan George Borges - 3/10/2009
It fills the BO with the selected record, and then navigates there too. instead it should: leave the BO as it is (keep all records as they are) and ONLY navigate to the selected record. dont re-populate. Well, this can only be accomplished if you have all records already populated in the form's BO, otherwise, you run the risk of selecting a record that is not populated in it yet. Anyway, I guess that if you follow what Trent told you, you can still do it. Create a second BO, populate it through the BD, once you get out of the BD, get the primary key of the select record and navigate the form's BO to it. You can even add the selected record to the form's BO with a bit of coding, if it is not there yet.
|
By Philipp Guntermann - 3/10/2009
Ivan George Borges (03/10/2009)
It fills the BO with the selected record, and then navigates there too. instead it should: leave the BO as it is (keep all records as they are) and ONLY navigate to the selected record. dont re-populate. Well, this can only be accomplished if you have all records already populated in the form's BO, otherwise, you run the risk of selecting a record that is not populated in it yet. Anyway, I guess that if you follow what Trent told you, you can still do it. Create a second BO, populate it through the BD, once you get out of the BD, get the primary key of the select record and navigate the form's BO to it. You can even add the selected record to the form's BO with a bit of coding, if it is not there yet. yes. i have the forms bo filled with all records. i was hoping i could use the browse-dialog to enable a search within theese and then have the bo being navigated to the selected record without having to create another bo. imo that is not an optimal solution. maybe i'll just relable the search button to "filter" or something, but i think the browsedialog should have a property of the selected pk that could be accessed directly / without having to create another bo.
|
By Ivan George Borges - 3/10/2009
imo that is not an optimal solution. OK, I guess we will just have to agree to disagree then! Since the BD is designed to search the database table, and not the BO, creating a second BO, just for the sake of the BD, wouldn't do any harm. And it would accomplish exactly what you are looking for. Just my 0.02 ... which in "reais" are even cheaper!
|
By Philipp Guntermann - 3/10/2009
i just think it could be a small addition to the browsedialog. and i think many people use it like that (have a form with a populated bo and then use browsedialog to enable a search).it would turn this code: private void btnSearch_Click(object sender, EventArgs e) { Business_Objekte.Basis.KundenBO ErgebnisBO = new Business_Objekte.Basis.KundenBO(); KVbrowseDialog.BusinessObjectToPopulate = ErgebnisBO; if (KVbrowseDialog.ShowDialog() == DialogResult.OK && ErgebnisBO.Count > 0) this.KVkundenBO.NavigateToPrimaryKey(ErgebnisBO.ID); ErgebnisBO.Dispose(); } into this much cleaner code: private void btnSearch_Click(object sender, EventArgs e) { if (KVbrowseDialog.ShowDialog() == DialogResult.OK && kvbrowseDialog.SelectedRowPK > 0) this.KVkundenBO.NavigateToPrimaryKey(kvbrowseDialog.SelectedRowPK); }
|
By Greg McGuffey - 3/11/2009
Philipp,
What you appear to want seems to be a bit more complicated than just getting the PK of the selected record. As Ivan said, the BD is going to query the database. That is what is designed for. However, since you have already pulled all the records over, this isn't really that efficient. It seems to me that what you want to do is to find the record within the existing set of data you've already pull over.
Now, to use the BD to do this could get complicated. You'd have to build a filter based on the search criterion in order to display the correct records, then return the selected record's PK so you could navigate to it in your BO. This might be possible by handling the various events, but I'm not real confident that it could even be done.
You might find it easier to just roll your own browse dialog, that simply looks up records within your prepopulated BO.
|
By Philipp Guntermann - 3/11/2009
Hi Greg,the first codesnippet in my post above actually does exactly what i want. i was just hoping for a cleaner way to do it, without the requirement to instanciate a temporary bo.
|
By Greg McGuffey - 3/11/2009
Yeah, I understand. I was just trying to point out that what you are doing is kind of running against the grain of how the BD works. This may work great in your situation, but it wouldn't work well in many others. I know I'm constantly attempting to reduce the trips to the database, reduce the amount of data returned, increase the efficiency of the queries I run because these all slow down the app. Thus, I wouldn't want to requery the database to get data I already had, which is what you are doing (you have a BO that already contains all the records, then you use to BD to query the database and get some subset of those records again). However, it may work fine for you, which is great.
Also, I don't think your suggested code would work because you still need to set a BO to populate that isn't your primary BO (otherwise it will reload that BO and you'll loose all the records not found). You might try to just sub-class the browse dialog, adding the desired functionality. You might add a generic method to replace the ShowDialog method that accepts the source BO and then does everything you need:
public class NavBrowseDialog : BrowseDialog
{
// Shows the browse dialog, populates a local BO (so the source BO
// remains unchanged) and then navigates the source BO to the
// selected record in the browse dialog.
// Params:
// boToNav:= source bo
public DialogResult ShowDialogAndNav<T>(BusinessLayer boToNav) where T: BusinessLayer, new()
{
T localBoToPopulate = new T;
this.BusinessObjectToPopulate = localBoToPopulate;
if (this.ShowDialog() == DialogResult.OK && localBoToPopulate.Count > 0)
{
boToNav.NavigateToPrimaryKey(localBoToPopulate.Items[localBoToPopulate.PrimaryKey]);
}
}
}
I'm not sure that the generic is strictly needed, but I think you do, so your local BO is of the correct type.
Now your code would be:
private void btnSearch_Click(object sender, EventArgs e)
{
KVbrowseDialog.MyShowDialog<Business_Objekte.Basis.KundenBO>();
}
|
By Trent L. Taylor - 3/11/2009
This is most likely not going to hapen within this release, Philipp as it doesn't fall in line with the current design. This is why we added the ReturnSeelctedRowOnly property to accomodate such needs. Greg's commentary is good, but in any case, I hope this at least gives you an answer so you can move forward. It was a good idea, but at the moment it is most likley not going to make it into the build. We will keep it on the table for a later date.
|
By Philipp Guntermann - 3/12/2009
Ok. Thanks.Have you had a look on the missing localization ?
|
By Trent L. Taylor - 3/12/2009
Not yet.
|
By hector - 11/29/2011
Hi Trent,
I am having the same difficulty for localizing the waitwindow.
The last message seems to be on 2009,
Could you please tell me if this is fixed with the new update and how can I localize it?
|
By Ivan George Borges - 11/29/2011
Hi Hector.
This hasn't made into the framework yet, but it certainly will.
For the time being, if you would like it to be localized, you could make a small change in the framework, as I have done.
First I created localization keys into my Message & Localization Project. Then I added code into the BrowseDialogWindow's SetFormTextValues method, as follows:
''' <summary> ''' Sets all of the forms text values (allows for localized values to be used) ''' </summary> Private Sub SetFormTextValues() '-- Establish Locals Dim loCVT As New KeysConverter
With _BrowseDialog Me.lblStatus.Text = String.Format(.EnterSearchCriteraStatusText, "[" & loCVT.ConvertToString(.SearchKey) & "]") Me.tsiSearch.Text = .SearchText Me.tsiClear.Text = .ClearText Me.cmdHideResults.Text = .HideResultsText Me.cmdSearchFields.Text = .SearchFieldsText Me.tscSearchFields.grpContent.Title = .SearchCriteriaText Me.chkAdvanced.Text = .AdvancedOptionsText Me.cmdOK.Text = .OKText Me.cmdCancel.Text = .CancelText End With
'-- IGB - added on 2011/04/08 - START '-- localize missing text key Try MyWaitwindow.Title = MicroFour.StrataFrame.UI.Localization.RetrieveTextValue("PFNT_MSG - BrowseDialogSearchingTitle") MyWaitwindow.Message = MicroFour.StrataFrame.UI.Localization.RetrieveTextValue("PFNT_MSG - BrowseDialogSearchingMessage") Catch ex As Exception End Try '-- IGB - added on 2011/04/08 - END End Sub
Hope it helps.
|
|