EasyUI Forum
April 29, 2024, 05:03:50 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: 1 ... 6 7 [8] 9 10
 71 
 on: October 14, 2023, 06:14:00 PM 
Started by Wojak - Last post by jarry
This code shows how to swap two rows in a datagrid.
Code:
var index1 = 2;
var index2 = 3;
var dg = $('#dg');
var rows = dg.datagrid('getRows');
var temp = rows[index1];
rows[index1] = rows[index2];
rows[index2] = temp;
dg.datagrid('refreshRow',index1);
dg.datagrid('refreshRow',index2);

 72 
 on: October 05, 2023, 03:28:17 PM 
Started by Wojak - Last post by Wojak
Hi,
I would like to add a button that allows the rows to be swapped up and down. I found a post from 2014, but it doesn't work Sad

https://www.jeasyui.com/forum/index.php?topic=3634.0

Snippet of the code
Code:
function dgSwapColumns(from, to) {
      $('#dg).datagrid('moveRow', { from: from, to: to });
}

It gives me this error
Code:
Uncaught TypeError: $.fn.datagrid.methods[_8ee] is not a function
    at $.fn.datagrid (<anonymous>:12356:35)
    at dgSwapColumns ((index):89:30)
    at HTMLAnchorElement.onclick ((index):1:1)

 73 
 on: September 27, 2023, 09:22:06 AM 
Started by lloyd - Last post by lloyd
Hi,

I have created a combobox search that lookup postcodes (zipcodes). But I do not want the the combobox text changed when the user selects an address.

How do I prevent combobox onSelect from changing (setting) the combobox textbox?

Code:
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Address Finder</title>
    <link href="js/easyUI/themes/metro/easyui.css" rel="stylesheet" type="text/css">
    <link href="js/easyUI/themes/icon.css" rel="stylesheet" type="text/css">
    <script src="js/easyUI/jquery.min.js" type="text/javascript"></script>
    <script src="js/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
</head>
<body>
    <div class="content">
        <p>(Free test code: WR5 3DA)</p>
        <input id="searchBox" class="easyui-combobox" style="width: 14%;" data-options="
            mode: 'remote',
            valueField: 'id',
            textField: 'name',
            required: true,
            label: 'Enter Address:',
            labelPosition: 'top',
            hasDownArrow: false,
            iconCls: 'icon-search',
            onSelect: findAddress,
            loader: loadAddresses
        ">
    </div>

    <script>
        var key = 'myKey';
        var isMiddleware = false;
        var origin = '';
        var countries = 'GBR';
        var limit = '10';
        var language = 'en-gb';
        var field1Format = '';

        function loadAddresses(param, success, error) {
            if (param === undefined) {
                return;
            }
            else {
                var q = param.q || '';
            }

            q = $.trim(q);

            if (q === '') {
                return;
            }

            $('.textbox-icon').last().removeClass('icon-search');
            $('.textbox-icon').last().addClass('icon-loading');
        
            $.ajax({
                url: 'https://services.postcodeanywhere.co.uk/Capture/Interactive/Find/v1.10/json3.ws',
                method: 'POST',
                data: {
                    Key: key,
                    Text: q,
                    IsMiddleware: isMiddleware,
                    Origin: origin,
                    Countries: countries,
                    Limit: limit,
                    Language: language
                },
                success: function(data) {
                    var items = $.map(data.Items, function(item) {
                        return {
                            id: item.Id,
                            name: item.Text + ' ' + item.Description,
                            description: item.Description,
                            text: item.Text,
                            type: item.Type
                        };
                    });

                    $('.textbox-icon').last().removeClass('icon-loading');
                    $('.textbox-icon').last().addClass('icon-search');

                    success(items);
                },
                error: function () {
                    error.apply(this, arguments);
                }
            });
        }

        function findAddress(record) {
            if (!record) {
                return;
            }

            $('.textbox-icon').last().removeClass('icon-search');
            $('.textbox-icon').last().addClass('icon-loading');
        
            var url = '';
            var params = '';
            var address = $(this).combobox('getText');

            params += 'Key=' + encodeURIComponent(key);

            if (record.type === 'Address') {
                url = 'https://services.postcodeanywhere.co.uk/Capture/Interactive/Retrieve/v1.00/json3.ws';
                params += '&Id=' + encodeURIComponent(record.id);
                params += '&Field1Format=' + encodeURIComponent(field1Format);
            }
            else {
                url = 'https://services.postcodeanywhere.co.uk/Capture/Interactive/Find/v1.10/json3.ws';
                params += '&Text=' + encodeURIComponent(address);
                params += '&IsMiddleware=' + encodeURIComponent(isMiddleware);
                params += '&Container=' + encodeURIComponent(record.id !== undefined ? record.id : '');
                params += '&Origin=' + encodeURIComponent(origin);
                params += '&Countries=' + encodeURIComponent(countries);
                params += '&Limit=' + encodeURIComponent(limit);
                params += '&Language=' + encodeURIComponent(language);
            }

            $.ajax({
                type: 'POST',
                url: url,
                data: params,
                success: function(data) {
                        if (record.type === 'Address') {
                            $('#searchBox').combobox('setValue', data.Items[0].PostalCode);
                        }
                        else {
                            var items = $.map(data.Items, function(item) {
                                return {
                                    id: item.Id,
                                    name: item.Text + ' ' + item.Description,
                                    description: item.Description,
                                    text: item.Text,
                                    type: item.Type

                                };
                            });
                            
                            $('#searchBox').combobox('loadData', items);
                            // Replace the selected value with the user's input
                            $('#searchBox').combobox('setValue', address);

                            $('.textbox-icon').last().removeClass('icon-loading');
                            $('.textbox-icon').last().addClass('icon-search');

                            $('.combo-panel').panel('open');
                        }
                    },
                    error: function () {
                        error.apply(this, arguments);
                    }
            });
        }
    </script>
</body>
</html>


 74 
 on: September 20, 2023, 06:16:45 AM 
Started by rezzonico - Last post by rezzonico
Thanks !

Regards
Miche

 75 
 on: September 10, 2023, 08:02:39 PM 
Started by rezzonico - Last post by jarry
Please refer to this example.
Code:
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title>ComboBox - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/icon.css">
<script type="text/javascript" src="https://www.jeasyui.com/easyui/jquery.min.js"></script>
<script type="text/javascript" src="https://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
<script>
$(function () {
var cc = $('#cc');
cc.combobox({
onChange: function (v) {
var g = $(this).next().find('.combobox-g');
var data = cc.combobox('getData');
var index = data.findIndex(r => r.value == v);
if (index >= 0) {
g.html(data[index].text);
} else {
g.html('');
}
},
onResize: function () {
var width = cc.combobox('textbox').css('width');
$(this).next().find('.combobox-g').css('width', width);
}
})
var tb = cc.combobox('textbox').hide();
var t = $('<div style="display:inline-block;height:28px;padding-top:6px;vertical-align:top"></div>').addClass('combobox-g').insertAfter(tb);
cc.combobox('resize');
})
</script>
</head>

<body>
<input id="cc" name="LineWidth" style="width:200px;" data-options="
   required: true,
   panelHeight: 'auto',
   editable: false,
   valueField: 'value',
   textField: 'text',
   value: '',
   data: [
      { value:'0', text:'<hr style=&quot;border-top: 0px solid&quot;>' },
      { value:'1', text:'<hr style=&quot;border-top: 1px solid&quot;>' },
      { value:'2', text:'<hr style=&quot;border-top: 2px solid&quot;>' },
      { value:'3', text:'<hr style=&quot;border-top: 3px solid&quot;>' },
      { value:'4', text:'<hr style=&quot;border-top: 4px solid&quot;>' },
      { value:'5', text:'<hr style=&quot;border-top: 5px solid&quot;>' }
   ]
">
</body>

</html>

 76 
 on: September 07, 2023, 08:11:08 AM 
Started by fmdano - Last post by larryclyons
Just bumping it up for notice. Thx jarry

 77 
 on: September 01, 2023, 09:29:54 AM 
Started by jega - Last post by jega
Ohh, just found it in another topic


$('#ff').form('submit', {
   onSubmit: function(){
      var form = $(this);
      var isValid = form.form('validate');
      if (!isValid){
         var field = form.find('.validatebox-invalid:first');
         var panels = $('#tabs').tabs('tabs');
         for(var i=0; i<panels.length; i++){
            var panel = panels;
            if (panel.has(field).length){
               var index = $('#tabs').tabs('select', i);
               setTimeout(function(){
                  field.focus();
               },0)
               break;
            }
         }
      }
      
      return isValid;
   }
})

 78 
 on: September 01, 2023, 09:24:30 AM 
Started by jega - Last post by jega
Hi.

On validation, how can i show the tab where the required textbox is ??


Jesper

 79 
 on: August 30, 2023, 12:06:15 PM 
Started by fmdano - Last post by fmdano
Hey all,
SO I have a tree grid. There are multiple rows deep. I need to click a link outside the grid where I pass in a value from the 3rd level down and need to get the grid to refresh and then expand level 1, and level 2 and then expand level 3 and select the row I passed in the id.
I know I can use this code: $(this).treegrid('expand', gridID).treegrid('select', gridIDSel);
if gridID is 1_1 then it will expand the first level and first row. Then inside level 2 gridIDSel: 2_6 then it will select that row.

If I want to highlight 3_22 then how can I expand 1_1 and 2_4 and then 3_20 (id's are examples)?
Do I need to use 3 different expand code lines where I know what the parent id is for the level 3 and then get the grand parent which is level 2 and great-grandparent for level 1, OR is there something where if i pass in a Level 3 id (3_22) to the expand code line, the all the above levels will expand?

Any thoughts on this? thanks...


 80 
 on: August 30, 2023, 03:42:41 AM 
Started by rezzonico - Last post by rezzonico
Hi,

I have a combobox where the user can select different line types.
In the drop-down list the lines are displayed correctly, but once a line is selected, in the combobox appears the HTML code.

Is it possible to display the line and not the code ?

See the code here:
http://217.193.156.220/jeasyui/BBB/

Thanks
Miche

Pages: 1 ... 6 7 [8] 9 10
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!