jQuery UI Widgets Forums Lists ListBox How to work with it if an item label property contains other language?

This topic contains 5 replies, has 2 voices, and was last updated by  andrewgo 10 years, 1 month ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author

  • andrewgo
    Participant

    $(“.listbox”).on(‘dragEnd’, function (event) {

    “.(‘removeItem’, ‘итем1’), “.(‘getItem’, ‘итем1’) both of them is not working.

    How can it be? I don’t want to use the listbox value property because i store some json there.

    Thank you.


    Nadezhda
    Participant

    Hello andrewgo,

    In the following example you can learn how to use “removeItem” to remove an item in another language: http://jsfiddle.net/fs3e2pwq/.

    Best Regards,
    Nadezhda

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


    andrewgo
    Participant

    If i use a source like this
    var source = [
    {label:”итем1″,value:{table:”foo”}},
    {label:”итем2″,value:{table:”foo”}},
    {label:”итем3″,value:{table:”foo”}},
    {label:”итем4″,value:{table:”foo”}},
    {label:”итем5″,value:{table:”foo”}}];

    The button and the code below are not working:
    $(“#jqxListBox”).on(“dragEnd”, function (event) {
    $(“#jqxListBox”).jqxListBox(‘removeItem’, event.args.label);
    }
    without any error messages.


    andrewgo
    Participant

    Though it’s not working with english labels too.


    Nadezhda
    Participant

    Hi andrewgo,

    If you use method “removeItem” then you have to pass the object returned by the “getItem” method or String – the value of an item (not the label).
    Here is an example with “removeItem” method that removes an item in another language:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta name="keywords" content="jQuery DropDownList, List, ListBox, Popup List, jqxDropDownList, jqxListBox, List Widget, ListBox Widget, DropDownList Widget" />
        <meta name="description" content="The jqxListBox represents a widget that contains a list of selectable items." />
        <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="../../scripts/demos.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxcore.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/jqxlistbox.js"></script>
        <script src="../../jqwidgets/jqxdragdrop.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                var source = [
                    { label: "итем1", value: "валуе1" },
                    { label: "итем2", value: "валуе2" },
                    { label: "итем3", value: "валуе3" },
                    { label: "итем4", value: "валуе4" },
                    { label: "итем5", value: "валуе5" }
                ];
    
                // Create a jqxListBox
                $("#jqxListBox").jqxListBox({
                    source: source,
                    theme: 'energyblue',
                    width: '200px',
                    height: '250px',
                    allowDrag:true,
                    selectedIndex: 3
                });
    
                $('#btn').on('click', function (event) {
                    $("#jqxListBox").jqxListBox('removeItem', "валуе1");
                });
            });
        </script>
    </head>
    <body>
        <div id='content'>
            <div id='jqxListBox'>            
            </div>
            <input style="margin-top: 20px;" type="button" id="btn" value="Remove 'итем1' from the list" />
        </div>
    </body>
    </html>

    Best Regards,
    Nadezhda

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


    andrewgo
    Participant

    That was helpful, thanks!

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

You must be logged in to reply to this topic.