Ext.NET DataView with KeyNav Support

  1. #1

    Ext.NET DataView with KeyNav Support

    I have been a big fan of DataView control since it a powerful, flexible, and optimizable control. The biggest concern was that it lacked keyboard navigation. After visiting Sencha DataView documentation, I thought it was pretty simple. Although this has not been tested with DataView having paging control, it works well otherwise.

    JavaScript Function

    <script type="text/javascript" language="javascript">
        var enter = function (dataView, dir) {
    
            //Get index of the last selected node (for multiple selection)
            var selectedIndex = Math.max.apply(Math, dataView.getSelectedIndexes());
    
            //No node was selected
            if (!selectedIndex) {
                //Initialize the index
                selectedIndex = 0;
            }
    
            //Count the total number of visible nodes.
            var totalItems = dataView.getNodes().length - 1;
    
            var nextIndex =
                            (
                                //If the selected node is the last item
                                //in the DataView
                                (selectedIndex + 1 > totalItems)
                                    ?
                                        //Goto the first node
                                        0
                                    :
                                        //Goto the next node
                                        selectedIndex + 1
                                );
            var previousIndex =
                            (
                                //If the selected node is first node
                                //in the DataView
                                (selectedIndex - 1 < 0)
                                    ?
                                        //Goto the last node
                                        totalItems
                                    :
                                        //Goto the previous node
                                        selectedIndex - 1
                            );
    
            switch (dir) {
                case "left":
                    dataView.select(previousIndex);
                    break;
                case "right":
                    dataView.select(nextIndex);
                    break;
            }
            return;
        };    
    </script>
    How to Use It?

    <ext:KeyNav ID="KeyNav1" runat="server" Target="={document.body}">
        <Left Handler="enter(#{YourDataViewID},'left');" />
        <Right Handler="enter(#{YourDataViewID},'right');" />
    </ext:KeyNav>
    Regards.
    Last edited by NickBin; Nov 19, 2011 at 4:35 PM. Reason: Correction
  2. #2

    Re:Confusion

    Hi Admins:

    The above post is an example of how we can use KeyNav along with DataView.

    This post has been moved from "examples and extras" to "help" section of this forum by mistake.

    Regards.
  3. #3
    Hi,

    Apologize.

    Just the question mark confused me.

    Quote Originally Posted by NickBin View Post
    How to Use It?
  4. #4

    Tested with DataView with Paging

    The above code has been tested with a DataView with a paging control and seems to work well.

    If you find any problems regarding the usage of the code, please feel free to contact me.

    Regards
  5. #5
    Ok.

    Thanks for the sharing the example. Looks good.
  6. #6

    good

    thank you very much I looking for this a long time but this is work good with DataView with out Ext.DataView.DragSelector

    like this

    https://examples1.ext.net/#/DataView/Basic/Overview/

    could you please fix it ?
  7. #7

    Re:

    Hi ramzey,

    I could not fully understand what you said.

    The scripts work fine with or without the plugin "Ext.DataView.DragSelector". Could you please post the markup if you have any problem.

    Lastly, please use the updated script from the following Url.

    http://forums.ext.net/showthread.php...ort-(Improved)

Similar Threads

  1. [CLOSED] RTL Support
    By imaa in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 11, 2013, 8:47 AM
  2. [CLOSED] DataView to DataView Drag and Drop
    By paulc in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: May 10, 2012, 8:19 PM
  3. Ext.NET DataView with KeyNav Support (Improved)
    By NickBin in forum Examples and Extras
    Replies: 3
    Last Post: Jan 20, 2012, 5:25 PM
  4. [CLOSED] KeyNav Tab Event Firing Inconsistently
    By dmoore in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 10, 2011, 1:09 PM

Posting Permissions