TextBox and search button in same cell
Hi There
I would like to have a TextBox and a search button in the same cell. When the user clicks the button, a pop-up window will display with a table, the user will select a value from the table in the pop-up and that value must populate the TextBox in the ggc with the selected value.
Thanks
I would like to have a TextBox and a search button in the same cell. When the user clicks the button, a pop-up window will display with a table, the user will select a value from the table in the pop-up and that value must populate the TextBox in the ggc with the selected value.
Thanks
SIGN IN To post a reply.
3 Replies
SN
Sridhar N
Syncfusion Team
June 23, 2011 02:01 PM UTC
Hi Glen,
Thanks for your interest in Syncfusion products.
Query #1"I would like to have a TextBox and a search button in the same cell. When the user clicks the button, a pop-up window will display with a table, the user will select a value from the table in the pop-up and that value must populate the TextBox in the ggc with the selected value."
Your requirement can be achieved by placing the TextBox and Button in the EditItemTemplate. Clicking the button will popup the grid and on selecting the record by doubleclicking the record will populate the TextBox in ggc with selected record value.Please refer the below code snippet.
[Codebehind - C#]
[Javascript]
For your convenience, we have created sample, video demonstrating the working of sample and the same can be downloaded from the following link.
Sample Link
Forum232919792.zip
Video Link
Popup666115360.zip
Please let us know if you have any other questions or concerns.
Regards,
Sridhar.N
Thanks for your interest in Syncfusion products.
Query #1"I would like to have a TextBox and a search button in the same cell. When the user clicks the button, a pop-up window will display with a table, the user will select a value from the table in the pop-up and that value must populate the TextBox in the ggc with the selected value."
Your requirement can be achieved by placing the TextBox and Button in the EditItemTemplate. Clicking the button will popup the grid and on selecting the record by doubleclicking the record will populate the TextBox in ggc with selected record value.Please refer the below code snippet.
[Codebehind - C#]
// RecordDoubleClicked event for setting the selected record value to TextBox in grid
void GridGroupingControl2_RecordDoubleClicked(object sender, RecordDoubleClickEventArgs e)
{
int rowindex = this.GridGroupingControl1.Table.CurrentRecord.GetRowIndex();
string ID, Name, Number, Telephone, Currency;
ID = e.Row.Record.GetValue("ID").ToString();
Name = e.Row.Record.GetValue("Name").ToString();
Number = e.Row.Record.GetValue("Number").ToString();
Currency = e.Row.Record.GetValue("Currency").ToString();
Telephone = e.Row.Record.GetValue("Telephone").ToString();
modalpopup1.Hide();
//Hidden data sent in RecordDoubleClicked event
this.TextModify.Value = ID + "," + Name + "," + Number + "," + Currency + "," + Telephone+","+rowindex;
}
//Search Button click event.
protected void Search(object sender, EventArgs e)
{
this.GridGroupingControl2.DataSource = this.GridGroupingControl1.DataSource;
Button btn = sender as Button;
GridCell cell = btn.Parent.Parent as GridCell;
TextBox text = (TextBox) cell.FindControl("SearchText");
this.GridGroupingControl2.TableDescriptor.RecordFilters.Clear();
RecordFilterDescriptor rfd = new RecordFilterDescriptor();
StringBuilder sb = new StringBuilder();
string searchtext = text.Text;
foreach (GridVisibleColumnDescriptor gcd in this.GridGroupingControl2.TableDescriptor.VisibleColumns)
{
sb.AppendFormat("[{0}] like '*{1}*' OR ", gcd.Name, searchtext);
}
//remove last ' OR '
sb.Remove(sb.Length - 4, 4);
rfd.Expression = sb.ToString();
//Adding filter from the textbox value.
this.GridGroupingControl2.TableDescriptor.RecordFilters.Add(rfd);
modalpopup1.Show();
}
[Javascript]
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args)
{
var hidden = document.getElementById('TextModify').value;
var temp = new Array();
temp = hidden.split(',');
var id = 'GridGroupingControl1~TR~0~_TOPGROUP_^' + (temp[5] - 3) + '*R0^ID';
var name = 'GridGroupingControl1~TR~0~_TOPGROUP_^' + (temp[5] - 3) + '*R0^Name';
var number = 'GridGroupingControl1~TR~0~_TOPGROUP_^'+(temp[5]-3)+'*R0^Number';
var currency = 'GridGroupingControl1~TR~0~_TOPGROUP_^'+(temp[5]-3)+'*R0^Currency';
var telephone = 'GridGroupingControl1~TR~0~_TOPGROUP_^'+(temp[5]-3)+'*R0^Telephone';
$('input[id="' + id + '"]').val(temp[0]);
$('input[id="' + name + '"]').val(temp[1]);
$('input[id="' + number + '"]').val(temp[2]);
$('input[id="' + currency + '"]').val(temp[3]);
$('input[id="' + telephone + '"]').val(temp[4]);
}
For your convenience, we have created sample, video demonstrating the working of sample and the same can be downloaded from the following link.
Sample Link
Forum232919792.zip
Video Link
Popup666115360.zip
Please let us know if you have any other questions or concerns.
Regards,
Sridhar.N
SI
singh
May 21, 2018 05:33 AM UTC
Same feature required in windows forms. Textbox with 2 buttons. one for search and one for clearing search. on search to open any form. and fill textbox after form closes. and on clear button to clear textbox text . Buttons should raise event . which will be handled on user code.
SN
Sindhu Nagarajan
Syncfusion Team
May 22, 2018 01:02 PM UTC
Hi Raman,
Thanks for using Syncfusion products.
We are able to understand your scenario. We have prepared a simple sample as per your requirement. In that sample, custom cell type has been created from GridTextBoxCell for having 2 buttons in a cell. Please refer to the below code, sample and video for your referernces.
Code Example
|
//Getting the record value
private void setBtn_Click(object sender, EventArgs e)
{
if(this.gridGroupingControl1.Table.SelectedRecords.Count > 0)
{
string text = this.gridGroupingControl1.Table.SelectedRecords[0].Record["CategoryID"].ToString();
record.SetValue("CategoryID", text);
}
}
//Creating instance to form2
private void GridGroupingControl1_TableControlCellButtonClicked(object sender, GridTableControlCellButtonClickedEventArgs e)
{
Record record = this.gridGroupingControl1.Table.DisplayElements[e.Inner.RowIndex].GetRecord();
if (e.Inner.Button.Text=="Search")
{
form2 = new Form2(this.gridGroupingControl1, record);
form2.Show();
}
else if (e.Inner.Button.Text == "Clear")
{
record.SetValue("CategoryID", string.Empty);
}
} |
Sample Link: http://www.syncfusion.com/downloads/support/directtrac/general/ze/GridGrouping-384747134
Video Link: Video
Please let us know if you have any other queries.
Regards,
Sindhu
SIGN IN To post a reply.
- 3 Replies
- 4 Participants
-
GT Glen Taylor
- Jun 22, 2011 08:25 AM UTC
- May 22, 2018 01:02 PM UTC