EasyUI Forum
September 16, 2025, 07:02:44 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: Read value  (Read 20955 times)
ClSoft
Jr. Member
**
Posts: 92


View Profile
« on: March 11, 2013, 03:18:08 PM »

Hi all
I have datagrid and button (Change member)
Under button, I call (onClick) ChangeMember() function, and here is it:

 function changeMember()
  {
    current = $('#members_tree').treegrid('getSelected').id;
    if (current){ 
      // Form
      $('#dlg').dialog('open').dialog('setTitle','Edit Member'); 
      $('#form_member').form('load', 'json/member.json');
      alert($('#zip').val());
    }     
  }

in JSON file, I have "zip" value, but alert is displayed too early, because form is still not filled.
When I click second time on same button, then I see value in alert, but I need it first time.
I try with onLoad event, but it is not fired on that point (onLoad is fired if I call 'load' from opened dialog).

Shortest - how to load JSON file and get some value?
THanks!
Logged
ClSoft
Jr. Member
**
Posts: 92


View Profile
« Reply #1 on: March 14, 2013, 01:54:11 PM »

Here is simple version, maybe someone help me now Smiley

      // Form
      $('#dlg').dialog('open').dialog('setTitle','Edit Member'); 
      $('#form_member').form('load', '/json/member.json');

      var zip = $('#zip').val();
      alert(zip);     

I have no value in alert first time, and if I call this code for different record, I see (in alert) value from previous record.
How to read value after dialog is opened ?
Thanks!
Logged
ClSoft
Jr. Member
**
Posts: 92


View Profile
« Reply #2 on: March 18, 2013, 12:40:17 AM »

OK maybe I need ask on this way:
how to fill form data (from JSON file) before form is opened?
Basically, I need to disable some fileds based on input value, and I can not do that because for is opened before I read JSON file.
Thanks!
« Last Edit: March 18, 2013, 07:04:46 AM by ClSoft » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: March 18, 2013, 09:25:10 AM »

Try the following code:
Code:
$.get('/json/member.json', function(data){
$('#dlg').dialog('open').dialog('setTitle','Edit Member');
$('#form_member').form('load', data);

var zip = $('#zip').val();
alert(zip);     
});
Logged
ClSoft
Jr. Member
**
Posts: 92


View Profile
« Reply #4 on: March 18, 2013, 11:40:57 PM »

Hello
Thanks stworthy, but...
I can not bring it to work Sad

This is what I have:
Under button, I call (onClick) ChangeMember() function, and here is complete function:

function changeMember()
  {
    current = $('#members_tree').treegrid('getSelected').id;
    if (current){ 
      $.get('/json/member.json', function(data){
        $('#dlg').dialog('open').dialog('setTitle','Edit Member');
        $('#form_member').form('load', data);
        var zip = $('#zip').val();
        alert(zip);     
      });
    }     
  }

I'm not sure that above is correct, so please tell me what's wrong?

this is JSON file:

{
    "firstname": "daniela",
    "lastname": "something",
    "zip": 2224
}

Thanks!
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #5 on: March 19, 2013, 07:32:16 PM »

Please refer to the attached example(form_test.zip).
Logged
ClSoft
Jr. Member
**
Posts: 92


View Profile
« Reply #6 on: March 20, 2013, 12:17:50 AM »

Thank you very much, but I can not bring it to work Sad
when I run it, I see empty message (see image).
When I click on OK, form is empty.
What I'm doing wrong?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #7 on: March 20, 2013, 12:36:25 AM »

It works fine in chrome,firebox and ie. Be sure to copy 'form_test.html' and 'member.json' files to your test directory on web server.
Logged
ClSoft
Jr. Member
**
Posts: 92


View Profile
« Reply #8 on: March 20, 2013, 02:13:07 AM »

Hi
yes, I uploaded it to webserver and there it works.
I need to see what's wrong on my local server.
Thanks!
Logged
ClSoft
Jr. Member
**
Posts: 92


View Profile
« Reply #9 on: March 21, 2013, 07:25:13 AM »

Just to inform you stworthy, it work's perferct.
thanks man!
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!