how to open the filter popup, set the focus on the textbox, when loading the grid.
thanks
9 Answers, 1 is accepted
I found this but it doesn't work.
dgvOrder.CurrentRow = dgvOrder.MasterView.TableFilteringRow;
dgvOrder.CurrentColumn = dgvOrder.Columns[3];
dgvOrder.BeginEdit();
You can use the following code for this:
protected
override
void
OnShown(EventArgs e)
{
base
.OnShown(e);
var cell = radGridView1.TableElement.GetCellElement(radGridView1.MasterView.TableHeaderRow, radGridView1.Columns[2])
as
GridHeaderCellElement;
cell.FilterButton.PerformClick();
}
I hope this will be useful. Let me know if you have additional questions.
Regards,
Dimitar
Progress Telerik
hi dimitar
thanks for the solution !
the call works as desired.
how can i set the focus on the search-textfield so that you can start directly with the input of the filtertext ?
regards
andre
I could not find a good way for this. The only solution would be to click the textbox with code when the popup is opened:
private
void
RadGridView1_FilterPopupInitialized(
object
sender, Telerik.WinControls.UI.FilterPopupInitializedEventArgs e)
{
var popup = e.FilterPopup
as
RadListFilterPopup;
if
(popup !=
null
)
{
popup.PopupOpened += Popup_PopupOpened;
}
}
private
void
Popup_PopupOpened(
object
sender, EventArgs args)
{
var popup = sender
as
RadListFilterPopup;
var textBox = popup.TextBoxMenuItem.HostedControl
as
RadTextBox;
Cursor.Position = popup.Location;
NativeMethods.PostMessage(
new
System.Runtime.InteropServices.HandleRef(popup, textBox.TextBoxElement.TextBoxItem.TextBoxControl.Handle), NativeMethods.WM_LBUTTONDOWN,0,0);
}
In addition, the textbox has correct size on my side. I have attached my test project. Could you please check it and let me know how it differs from your real setup?
I am looking forward to your reply.
Dimitar
Progress Telerik
hi dimitar
many thanks for the sample application.
the textbox has the right size in your example. however the click into the textbox doesn't seem to work. i still have to click into the textbox before writing anything.
the goal is to get an input possibility for filtering without using the mouse.
hi dimitar
Is there any reason why this
textBox.focus();
isn't working?
The mistake is mine. You need to send a mouse up message as well. This way you will be able to directly type in the text box:
NativeMethods.PostMessage(
new
System.Runtime.InteropServices.HandleRef(textBox.TextBoxElement.TextBoxItem.TextBoxControl, textBox.TextBoxElement.TextBoxItem.TextBoxControl.Handle), NativeMethods.WM_LBUTTONDOWN,0,0);
NativeMethods.PostMessage(
new
System.Runtime.InteropServices.HandleRef(textBox.TextBoxElement.TextBoxItem.TextBoxControl, textBox.TextBoxElement.TextBoxItem.TextBoxControl.Handle), NativeMethods.WM_LBUTTONUP, 0, 0);
The cursor needs to be somewhere in the popup because otherwise the popup will be closed (the popup will receive the message as well). Just calling the Focus method would not work because the textbox is inside a popup which is a separate window. This method is inherited from the standard controls and we do not have control over this functionality.
Let me know if you have additional questions.
Regards,
Dimitar
Progress Telerik
hi dimitar
exactly what it was. Works as desired.
thank you very much for the excellent support.
regards,
andre