jQWidgets Forums

jQuery UI Widgets Forums Grid Last Focused Cell Keyboard

This topic contains 1 reply, has 2 voices, and was last updated by  Nadezhda 10 years, 1 month ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Last Focused Cell Keyboard #68118

    kxtruong
    Participant

    I’m trying to find what the last focused cell is. For example if I used the keyboard (Shift + Up keys)to select a few cells I want to find out which cell was the cell I last focused on. I was looking at the cellselect event but what happens is that the cellselect event fires for the recent cell selection added that I focused on and then re-fires all the cellselect events for every other cell is currently selected (The last cell select event fired is whichever cell that is furthest to bottom right).

    Is there a way to keep track of the last cell that I selected using keyboard navigation?

    Thank you,
    Kenneth

    Last Focused Cell Keyboard #68121

    Nadezhda
    Participant

    Hello Kenneth,

    Here is an example:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <title></title>
        <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
        <script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.edit.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script>
        <script type="text/javascript" src="../../scripts/demos.js"></script>
    </head>
    <body>
        <div id='content'>
            <script type="text/javascript">
                $(document).ready(function () {
                    var url = "../sampledata/orders.xml";
                    // prepare the data
                    var source =
                    {
                        datatype: "xml",
                        datafields: [
                            { name: 'ShippedDate', map: 'm\\:properties>d\\:ShippedDate', type: 'date' },
                            { name: 'Freight', map: 'm\\:properties>d\\:Freight', type: 'float' },
                            { name: 'ShipName', map: 'm\\:properties>d\\:ShipName', type: 'string' },
                            { name: 'ShipAddress', map: 'm\\:properties>d\\:ShipAddress', type: 'string' },
                            { name: 'ShipCity', map: 'm\\:properties>d\\:ShipCity', type: 'string' },
                            { name: 'ShipCountry', map: 'm\\:properties>d\\:ShipCountry', type: 'string' }
                        ],
                        root: "entry",
                        record: "content",
                        id: 'm\\:properties>d\\:OrderID',
                        url: url
                    };
    
                    var dataAdapter = new $.jqx.dataAdapter(source);
    
                    // create jqxgrid.
                    $("#jqxgrid").jqxGrid(
                    {
                        width: 670,
                        height: 300,
                        source: dataAdapter,
                        editable: true,
                        editmode: 'selectedcell',
                        keyboardnavigation: true,
                        ready: function () {
                            // focus jqxgrid.
                            $("#jqxgrid").jqxGrid('focus');
                        },
                        selectionmode: 'multiplecellsadvanced',
                        columns: [
                          { text: 'Ship Name', datafield: 'ShipName', width: 250, align: 'left', cellsalign: 'left' },
                          { text: 'Freight', datafield: 'Freight', width: 80, align: 'right', cellsformat: 'F2', cellsalign: 'right' },
                          { text: 'Ship Address', datafield: 'ShipAddress', align: 'left', width: 350, cellsalign: 'left' },
                          { text: 'Ship City', datafield: 'ShipCity', width: 100, align: 'left', cellsalign: 'left' },
                          { text: 'Ship Country', datafield: 'ShipCountry', align: 'left', cellsalign: 'left' }
                        ]
                    });
    
                    $("#jqxgrid").keyup(function () {
                        var cell = $('#jqxgrid').jqxGrid('getselectedcell');
                        alert(cell.value);
                    });
                });
            </script>
            <div id='jqxgrid'>
            </div>
        </div>
    </body>
    </html>

    I hope it would be helpful.

    Best Regards,
    Nadezhda

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.