v
Not logged inv
SearchAsk a QuestionReport an IssueMake a SuggestionMy Questions and Issues
Issue Details
Find By ID

popupcontaineredit incremental search

Issue Details

Log in to Track Changes or Edit
Q206739
Question
Stefan Haug
Yes
Processed
Answered
.NET
XtraEditors Library
9.1.3
Windows Vista
Microsoft Visual Studio 2008
3/18/2010 12:12:39 PM
-> Created by Stefan Haug 5/22/2009 10:07:19 AM

Attachment: PopupContainerIncrementalSearch.zip (76475 bytes)

Hi,

I'm trying to create a lookup editor that updates a different field than the one it's bound to. This was no problem when I used the InfoPower components for Delphi, but I cannot find a similar functionality in DevExpress.

Anyways, attached is a project that i'm working on trying to get this to work.

What I wish to accomplish is the ability to have incremental search on the description field so that the user can select a product from a grid by pressing enter, or enter a custom text. If the user selects a product, the description is set to the product's name and the GTIN is updated.

I'm not sure i'm making myself perfectly clear, but I hope my intentions are revealed.

The goal is for the user to quickly be able to select the correct product and optionally change the description later (without removing the product association).

I hope you can give me some clues towards a final solution.

Thanks,
Stefan

-> Updated by Stefan Haug 5/22/2009 10:08:45 AM

Additional information:

The focus should not be lost in the editor when the popup window is displayed, but rather have the text the user has entered so far, followed by a selection of the remaining text of the found product (if any), much like auto completion.

Thanks,
Stefan

<- Reviewed by DevExpress Team 5/22/2009 1:20:49 PM
<- Processed (Answered) by DevExpress Team 5/22/2009 3:14:02 PM

Hello Stefan,

Thank you for the question. I'm afraid that there is no way to activate the incremental search feature using the PopupContainerEdit control. However, you can use the LookupEdit for this purpose. Could you please clarify why this control doesn't meet your requirements? If you need to obtain a specific column's value when a user selects an entry from the drop-down list, it is possible, as described in the How to obtain a value for a specific column within the LookupEdit which corresponds to the currently selected row knowledgebase article. It would be great if you prepare a simple sample based upon the LookUpEdit control, and describe the expected result in a step-by-step fashion.

I'm awaiting your response.

Thanks,
Stan.

-> Reactivated by Stefan Haug 5/22/2009 6:45:00 PM

Hi Stan,

Thank you for your reply. I will use this new information and examine it on monday. Then I will create a small sample project and hopefully it´ll work as I intended.

In the mean time I will explain in greater detail what behaviour I wish.

Firstly, the scenario I´m working on is the traditional customer order form, where the order details are listed on top, with orderlines in a grid below.

One column should contain the product id (if any) while the other column should contain the description of the line in question. The description field should be editable but gets the name of the selected product by "default" whenever the user selects a product for the line. Creating a lookup for the product id column is no problem since it´s the same text being displayed as the text being in the lookup.

The description field however should also provide the ability to lookup a product, but rather by the product name - while being databound to the description field! :) do you see my dilemma?

Anyways, as I said I´ll try to create a close to complete sample on monday.

Have a nice weekend,
Stefan

-> Updated by Stefan Haug 5/25/2009 8:14:58 AM

Attachment: PopupContainerIncrementalSearch.zip (78017 bytes)

Hi Stan,

Attached you will find the project wher i've tried to implement your suggestion. It does not work however. I would greatly appreciate your expertise in this matter.

Like i've explained previously i'm trying to implement the following functionality:
* Two lookup columns in the orderlines grid - GTIN and Description.
* The GTIN lookup is easy. It sets the Product! field while displaying the Product.GTIN property.
* The Description column should display the text from the Description property.
* The Description column should have a lookup that enables the users to quickly select a product using the lookup.
* The Description column should be editable, so that the users may change the description even if a product has been selected.
* Changing the description should not invoke the lookup and change the currently assigned product.

The problem here is that the Description field is bound to the Description field while having a lookup of the Product class type.

A component from Woll2Woll's InfoPower suite called Advanded Combobox had this ability and I dearly miss it.

I hope you can assist me in this Stan.

Thanks,
Stefan

<- Processed (Insufficient Information) by DevExpress Team 5/25/2009 11:46:16 AM

Hi Stefan,

I'm afraid it is impossible to use one column for editing values in different fields. A column can be bound only one field, and changing a value in an editor will result in changing the value in the column. This limitation can be avoided by displaying an editor, that isn't bound to this column over a cell if a user clicks within this cell, but doesn't click the drop-down button. Unfortunately, in your situation it is impossible, because you need to show a description for the specified Product. However, it's impossible to get a description having only the Product object, because it has no reference to a certain OrderLine object. Is it possible to introduce the OrderLine property in the Product class, referencing the OrderLine object this product belongs to? If it's possible, I'll create a sample project, demonstrating how to implement this.

I'm looking forward to hearing from you.

Thanks,
Uriah.

-> Reactivated by Stefan Haug 5/25/2009 12:09:20 PM

Hi Uriah,

Thank you for your reply.

Let my phrase myself a little differently...

Is it possible to have a lookup that is <b>not</b> databound to the current column, but where it's possible to update a property for the current row?

The description field is common for all kinds of orderlines so the product does not need to know this. I was thinking of updating the description field if a new product was selected.

Thanks,
Stefan

<- Processed (Answered) by DevExpress Team 5/26/2009 8:19:27 AM

Attachment: Q206739.ZIP (17484 bytes)

Hi Stefan,

You are right, since a value of the Description column can be obtained from a focused row, this task can be accomplished without having a reference to an OrderLineProduct object within the Product class. I have created a sample project, demonstrating how to implement this. However, I'd like to recommend that you avoid using such tricks where possible, because this scenario contradicts with common data editing scenarios supported by the XtraGrid. In your situation, there is no other way. Anyway, I believe that a safer approach is to edit values of the Description property in a separate column.

Thanks,
Uriah.

-> Reactivated by Stefan Haug 5/26/2009 8:44:14 AM

Hi,

Thank you for your sample. I couldn't quite get it to work - a editor got created in the upper lefthand corner when i clicked the button.

Anyways, is it possible to show the popup window of a popupcontaineredit without it being focused?

Thanks,
Stefan

<- Processed (Answered) by DevExpress Team 5/26/2009 10:28:18 AM

Hi Stefan,

To show an editor above an appropriate cell, use the ShowEditor(Rectangle bounds) method. You should put a cell's bounds to this method as a parameter. Please review the gvLines_ShowingEditor method implementation. Also, I have set the e.Cancel property to true, to prevent the column's editor from being shown before the ButtonEdit.

>> is it possible to show the popup window of a popupcontaineredit without it being focused?
No, if the editor isn't shown, you can't access it.

Thanks,
Uriah.

-> Reactivated by Stefan Haug 5/26/2009 10:46:53 AM

Hi Uriah,

Like you, I don't much like the idea of showing a seperate editor on top of the column. This is too much a trick for my liking.

>>>> is it possible to show the popup window of a popupcontaineredit without it being focused?
>>No, if the editor isn't shown, you can't access it.

I mean that the popup window is displayed (ShowPopup) but focus remains in the column.

Thanks,
Stefan

<- Updated by DevExpress Team 5/27/2009 8:23:40 AM

Hi Stefan,

Please give me additional to research the issue. I'll provide you with a sample project as soon as possible.

Thanks,
Uriah.

-> Updated by Stefan Haug 5/27/2009 8:35:37 AM

Hi Uriah,

Thank you. What I was thinking was that if this was possible, I could allow the user to enter text into the column and I could filter the grid inside the popup window based on the text the user entered into the field. Then if the user presses ENTER i close the popup and handle the QueryResultValue. Tabbing out of the column closes the popup window without triggering the QueryResultValue.

So if it's possible to display the popup window while retaining focus in the column, this would be my version of an incremental search for a popupcontaineredit :)

Looking forward to hearing from you,
Stefan

<- Processed (Answered) by DevExpress Team 5/28/2009 10:22:32 AM

Attachment: Q206739.ZIP (18072 bytes)

Hi Stefan,

Sorry for the delay in responding. Attached is a sample project, demonstrating how to achieve this task using the LookUpEdit. To accomplish this, you need to bind the DisplayMember property of the LookUpEdit to a field that isn't represented in the LookUpEdit's data source and populate this field with custom values within the LookUpEdit.GetNotInListValue event handler. Within the LookUpEditBase.ProcessNewValue event handler, update the Description property and prevent the currently selected Product from being set to null by calling the GridView.HideEditor method.

This approach isn't simple, so, if you've already implemented the same feature using the PopupContainerEdit in an easier manner, feel free to use your approach. To activate an editor, when the pop-up form is shown, call the PopupContainerEdit.Focus method. You can get the PopupContainerEdit via the GridView.ActiveEditor property.

[C#]

gvLines.ActiveEditor.Focus();

Please let me know if you need any further assistance.

Thanks,
Uriah.

-> Reactivated by Stefan Haug 5/28/2009 12:54:57 PM

Attachment: PopupContainerFocus.zip (78135 bytes)

Hi Uriah,

Thank you for your sample. Unfortunately I did not like this approach, and have decided to find another solution.

Opening a popup window and keeping focus in the editor is a good solution. I can handle the ENTER, UP and DOWN keys to do selection and besides that update the filter row by by setting it's cell values. This very much works like what i had in mind.

Attached you will find my sample project.

I have a few minor problems though.

1. If you open the popup window in the "new item" position, i must call the AddNewRow() method which results in another call to QueryResultValue. I must handle this by using a "update" block. Maybe the 2nd call is important somehow and related to the other problem?
2. I'm unable to reflect changes to the Description column after setting the product.

Looking forward to hearing your insight on this.

Thanks,
Stefan

<- Processed (Answered) by DevExpress Team 5/28/2009 4:05:48 PM

Hi Stefan,

1. I'm afraid that your requirements aren't clear to me. Basically, this isn't causing any side effect. However, if you simply need to append the row currently edited within the NewItemRow, I suggest that you call the GridView.UpdateCurrentRow method within the PopupContainerEdit.CloseUp event handler. Please see the code below:

[C#]

private void pceDescription_CloseUp(object sender, DevExpress.XtraEditors.Controls.CloseUpEventArgs e) {
    if (gvLines.FocusedRowHandle != GridControl.NewItemRowHandle) return;
    gvLines.CloseEditor();
    gvLines.UpdateCurrentRow();
}

2. Could you please describe this problem in greater detail? Since the pceDescription is bound to the Description column, all that you need is to provide the value within the QueryResultValue event, and you already implement it. Does this approach work incorrectly in some situations, or not meet your requirements? Please provide me with the steps I should perform to see the problem. I'm looking forward to hearing from you.

Thanks,
Uriah.

-> Reactivated by Stefan Haug 5/29/2009 10:58:47 AM

Hi Uriah,

Firstly, thank you for your endless patience. I very much appreciate it.

You are correct. I am unable to reproduce this issue using the sample I uploaded previously. I must have worked on a modified version or something - I apologize for this.

As for the QueryResultValue being called twice, if you cannot see any side effects with this I will trust your word. It just seemed odd to me that I had to use a update-block. Without it, two lines are added :)

Thank you for your assistance Uriah, I like this solution better.

- Stefan

<- Processed (Answered) by DevExpress Team 5/29/2009 11:29:04 AM

Hi Stefan,

Thank you for the feedback. Instead of adding a new row, you can try to update the NewItemRow after it has been edited. In this situation, the unnecessary row shouldn't be added. Please see the code below:

[C#]

private void pceDescription_QueryResultValue(object sender, DevExpress.XtraEditors.Controls.QueryResultValueEventArgs e)
{
    //if (queryResultValueUpdating) return;
    try
    {
        queryResultValueUpdating = true;
        PopupContainerEdit edit = sender as PopupContainerEdit;
        // Set the product
        Product p = gvProducts.GetFocusedRow() as Product;
        if (p != null)
        {
// current is null if positioned in the NewItemRow position, and the popup is displayed without changing any other values
            object current = gvLines.GetFocusedRow();

            //if (current == null) gvLines.AddNewRow();
            BeginInvoke(new MethodInvoker(UpdateNewRow)); // NEW LINE

            e.Value = p.Name;
            gvLines.SetRowCellValue(gvLines.FocusedRowHandle, colProduct, p);
        }
    }
    finally
    {
        queryResultValueUpdating = false;
    }
}

private void UpdateNewRow() {
    gvLines.PostEditor();
    gvLines.UpdateCurrentRow();
}

Please feel free to contact us again in case of any difficulty.

Thanks,
Uriah.

<- Processed (Customer Closed) by Stefan Haug 3/18/2010 12:12:39 PM
Log in to Track Changes or Edit

Peer-to-Peer Discussion in DevExpress Forums

No discussion on this article has been started yet.

Please login to start discussion.

v
v
Search
Searching Tips