EasyUI Forum
April 19, 2024, 10:18:14 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: getEditor and getEditors always returning NULL  (Read 12306 times)
rannacher
Jr. Member
**
Posts: 52


View Profile
« on: November 25, 2015, 12:21:36 PM »

I loop trough datagrid and need to read values from combobox field = TAGESKENNUNG with typeid and typename in editor defined. But all I get is the value which is contained in the rows object itself, but how to access typeid and typename for a row?
 
  rows = $('#dg').datagrid('getRows');
    for(var i=0; i<rows.length; i++)
    {
       // works fine
       $('#dg').datagrid('getRows').TAGESKENNUNG;

      // any of below 2 lines DOES NOT WORK
       var editors = $('#dg').datagrid('getEditors', i);
       var ed = $('#dg').datagrid('getEditor', {index: i, field:'TAGESKENNUNG'});

     // actually I need to access and maybe write back later the two fields typeid and typename of TAGESKENNUNG
    }

PLEASE PLEASE HELP and THANK YOU a lot in advance!

Logged
rezzonico
Full Member
***
Posts: 182


View Profile
« Reply #1 on: November 26, 2015, 01:33:09 PM »

I am not sure but you must call "beginEdit" before calling "getEditor".

Regards
Miche
Logged
rannacher
Jr. Member
**
Posts: 52


View Profile
« Reply #2 on: November 27, 2015, 02:59:03 AM »

rezzonico, thx.

You mean getEditor/getEditors only works when in Editmode?

I just need to loop  through all data rows and get the value/text of a combobox item in the row.
I get all other row data of course, but not both variables for the combobox.
(accessing datagrid data or the row object only returns combobox selection)

Any idea how to do?
Logged
rezzonico
Full Member
***
Posts: 182


View Profile
« Reply #3 on: November 28, 2015, 04:59:30 AM »

In the field typeid of the combobox you could store both values: typeid and typename (and join then with "~")

The json data could be:
[{"typeid":"100~john","typename":"john"}]

Then you can read typeid it with "rows.TAGESKENNUNG" and use split it in order to get both values (typeid and typename).

Probably there are better solutions ...
« Last Edit: November 28, 2015, 05:02:01 AM by rezzonico » Logged
rannacher
Jr. Member
**
Posts: 52


View Profile
« Reply #4 on: November 28, 2015, 04:43:02 PM »

rezzonico, thx gain, appreciate.

Wit such change I would affect entire rest of code.
Cannot believe it is not possible to access editor defined in datagrid row???
I made test now and it seems you really have to be in edit mode.
But what when you just loop through data after all editing is done for saving purpose...
Any idea?

Greetings and Thank you very much!!!

BR Michael.
Logged
rezzonico
Full Member
***
Posts: 182


View Profile
« Reply #5 on: November 29, 2015, 12:44:19 AM »

I do not see how to read typename without enter in edit mode.
But when writing to the database from a combobox, I would only write the typeid (and not the typename).
It seems me that if you also write the typename, this is a redundancy and the database is not normalized.
But if you really need to write both, before writing to the database you can re-read the typename (from the database).
« Last Edit: November 29, 2015, 12:05:15 PM by rezzonico » 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!