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

Turn navigation off in header.

3 Answers 18 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Scott Marx
Top achievements
Rank 1
Scott Marx asked on 04 Oct 2013, 06:51 PM
I have a grid using a customer filter that is appended to the thead. On a keydown event of the customer filter field, the focus is moved to first data field of the grid. How do I prevent the focus change?

Section of code in question;
var timeout;
var filter = { logic: "and", filters: [] };
var filterRow = $('<tr><td><input type="search" id="programCodeFilter" class="k-textbox" style="width:75px;"></td><td><input type="search" id="lenderProgramNameFilter" class="k-textbox" style="width:75px;"></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>')
detailGrid.data("kendoGrid").thead.append(filterRow);
 
detailGrid.find("input#programCodeFilter").keydown(function () {
    var filterExpr = { field: "ProgramCode", operator: "startswith", value: "" }
    var fc = 0;
    if (filter.filters.length > 0) {
        for (var i = filter.filters.length - 1; i >= 0; i--) {
            if (filter.filters[i].field == 'ProgramCode') {
                var rmFilter = filter.filters[i];
                rmFilter.value = this.value;
                fc++;
            }
        }
        if (fc == 0) {
            filter.filters.push(filterExpr);
        }
    } else {
        filterExpr.value = this.value;
        filter.filters.push(filterExpr);
    }
 
    clearTimeout(timeout);
    timeout = setTimeout(function () {
        detailGrid.data("kendoGrid").dataSource.filter([filter]);
    }, 100);
});

3 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 07 Oct 2013, 09:50 AM
Hi Scott,

You can prevent event bubbling in your handler, so that the Grid does not capture the keydown event.

http://api.jquery.com/event.stopPropagation/

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Scott Marx
Top achievements
Rank 1
answered on 07 Oct 2013, 04:49 PM
This is a google type search in the Grid Header, would that prevent it from firing in the header as well?
0
Dimo
Telerik team
answered on 08 Oct 2013, 07:07 AM
Hi Scott,

The Grid keyboard navigation uses keydown, mousedown and touchstart event handlers attached to the header <table> and the data <table> elements. If you prevent bubbling for those events (only the ones that you need actually) before they propagate to the <table> elements, you'll be fine, no matter what is your exact scenario.

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Scott Marx
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Scott Marx
Top achievements
Rank 1
Share this question
or