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

[Solved] default button on Enter key

3 Answers 157 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Gerard Eikelboom
Top achievements
Rank 1
Gerard Eikelboom asked on 25 Nov 2010, 10:42 AM
In our telerik grid we have a column in it a button
columns.Bound(v => v.Koop).Width(45)
                    .HeaderHtmlAttributes(new { title = "Buy direct" })
                    .Filterable(false)
                    .ClientTemplate("<input type='button' value=' ' text='BesteldAantal' class='koopbutton'/>");

When I look a this button at runtime it gets as Id the row number it is in.

The column before this one is a textbox column.
columns.Bound(v => v.BesteldAantal).Width(70)
                    .Filterable(false)
                    .ClientTemplate(Html.TextBox("BesteldAantal",string.Empty, new { @class = "besteldaantal"}).ToString());
What I like to have is when I filled out the textbox with something and when I hit enter the button beside it is fired.

Is this possible?

Regards,
Gerard

3 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 26 Nov 2010, 05:32 PM
Hello Gerard,

You can bind the keyup event on the input and simulate the click from the event handler. The most convenient place to do so is in the onRowDataBound client-side event:

function Grid_onRowDatabound(e)
{
    $(".besteldaantal", e.row).keyup(function(keyUpEvent) {
        if (keyUpEvent.keyCode == 13)
            $(".koopbutton", e.row).click();
    });
}

I'm attaching you a sample project that demonstrates this approach.

Greetings,
Tsvetomir Tsonev
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
Gerard Eikelboom
Top achievements
Rank 1
answered on 02 Dec 2010, 11:01 AM
Thank you Tsvetomir Tsonev,

Worksvery well.
0
Hernan
Top achievements
Rank 1
answered on 03 Jan 2011, 05:26 PM
How can do that but on the popup editor ?? When i press enter on text box the page fires a full postback.


Sorry for my english..

Best regards !!!!
Tags
Grid
Asked by
Gerard Eikelboom
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Gerard Eikelboom
Top achievements
Rank 1
Hernan
Top achievements
Rank 1
Share this question
or