EasyUI Forum
October 16, 2025, 11:12:15 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Passing the combobox value to the datagrid validType function  (Read 12476 times)
rezzonico
Full Member
***
Posts: 186


View Profile
« on: November 18, 2015, 09:49:50 AM »

Hi all,

I have a combobox and a datagrid.
I need to pass the combobox value to the datagrid validType function.

Here is my non-working code.

Any help is appreciated.

Regards.
Miche

Code:
   <script type="text/javascript">
      $(function(){
         $('#Year').combobox({
            onChange: function() {
               $('#dg').datagrid('load',{});
            }
         });

         $('#dg').datagrid({
            validType: 'remote["dovalidate.cgi?Year=", $('#Year').combobox('getValue')]'
            ...
         });
      });
   </script>

   <div>
      <select class="easyui-combobox" id="Year" data-options="editable: false">
         <option value="2010">2010</option>
         <option value="2011">2011</option>
         <option value="2012">2012</option>
      </select>
   </div>

   <div>
      <table id="dg" border="true">
      </table>
   </div>
« Last Edit: November 18, 2015, 09:57:21 AM by rezzonico » Logged
jarry
Administrator
Hero Member
*****
Posts: 2300


View Profile Email
« Reply #1 on: November 18, 2015, 06:25:32 PM »

The 'validType' property is not defined in datagrid plugin. What would you do with this property?
Logged
rezzonico
Full Member
***
Posts: 186


View Profile
« Reply #2 on: November 19, 2015, 07:24:04 AM »

Hi jarry,

sorry ... I tryed to semplify my code but I removed too many lines.

I have a combobox (for selecting the Year) and a datagrid.
In my datagrid I have the field Col1.
The editor type of Col1 is a combogrid.
In the options I use "validType" with the remote program "dovalidate.cgi".
The variable Year is passed to the validation program (dovalidate.cgi).

All works perfectly.
The only problem is that the program "dovalidate.cgi" always receive "Year=2010" also after selecting a new year in the combobox.

In other words ... the value of the variable Year (passed to the program "dovalidate.cgi") is not updated with the current value of the combobox.

Thanks for your help.
Miche

Code:
   <script type="text/javascript">
      var Year = 2010;

      $(function(){
         $('#Year').combobox({
            onChange: function(value) {
               Year = value;
               $('#dg').datagrid('load',{});
            }
         });

         $('#dg').datagrid({
            {field:'Col1',title:'Col1',
               editor: {
                  type: 'combogrid',
                  options: {
                     validType: 'remote["dovalidate.cgi?Year=" + Year, "Col1"]'
                  }
               }
            }
         });
      });
   </script>

   <div>
      <select class="easyui-combobox" id="Year" data-options="editable: false">
         <option value="2010">2010</option>
         <option value="2011">2011</option>
         <option value="2012">2012</option>
      </select>
   </div>

   <div>
      <table id="dg" border="true">
      </table>
   </div>
« Last Edit: November 19, 2015, 07:32:59 AM by rezzonico » Logged
StefaanEeckels
Newbie
*
Posts: 12


View Profile
« Reply #3 on: November 19, 2015, 08:44:21 AM »

The problem is that the function is evaluated when the handler is installed, not when it is called. You could try something lile this:

               editor: {
                  type: 'combogrid',
                  options: {
                     validType: makeURL(),
                  }
               }

...
function makeURL() {
    var Year = Math.floor($('#Year').combobox('getValue'));
    return 'remote["dovalidate.cgi?Year=" + Year, "Col1"]';
}
Logged
rezzonico
Full Member
***
Posts: 186


View Profile
« Reply #4 on: November 20, 2015, 01:35:07 AM »

Thanks for your help !
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!