This is a migrated thread and some comments may be shown as answers.

[Solved] bubbling events from custom columns

2 Answers 119 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alon Agmon
Top achievements
Rank 1
Alon Agmon asked on 25 May 2010, 10:26 PM
Hi,
what is the proper way, to programmaticly  create a custom bounded column with a button + text field, while the on_click event need to be bubbled outside to trigger a java script function ?
( i dont really need an "edit mode" - it will always stays in edit mode)
and also if i want to receive a value externally and update the text field in response to that 

what is the best way to achieve that 

Alon 


2 Answers, 1 is accepted

Sort by
0
Accepted
Pavel Pavlov
Telerik team
answered on 26 May 2010, 08:02 AM
Hello Alon Agmon,

The straightforward way would be to place a button inside the CellTemplate using the Column.CellTemplate property.
Subscribe to the click event of that Button. Within the event handler use the HTML bridge to call the relevant javascript function.

Something like :
<grid:GridViewDataColumn                    <grid:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <Button Width="100" Height="20" Click="Button_Click_1" Content="Test" />
                        </DataTemplate>
                    </grid:GridViewDataColumn.CellTemplate>
                </grid:GridViewDataColumn>
private void Button_Click_1(object sender, RoutedEventArgs e)
      {
          HtmlPage.Window.Invoke("Alert", "Test button clicked");
      }

I have tested the code above  to successfully call the javascript Alert function on click of a button in the cell.

Sincerely yours,
Pavel Pavlov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Brad
Top achievements
Rank 1
answered on 18 Aug 2011, 01:26 PM
.
Tags
GridView
Asked by
Alon Agmon
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Brad
Top achievements
Rank 1
Share this question
or