EasyUI Forum
October 16, 2025, 04:38:34 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: datagrid, filter row and combobox  (Read 11784 times)
Fabrice
Jr. Member
**
Posts: 62


View Profile
« on: September 17, 2015, 08:34:42 AM »

I write this function to fill a combobox with datagrid content in OnLoadSuccess() event :
Code:
var rows = $(dd).datagrid('getData');
        $.each(filters, function (num_filter, filter) {
            if (filter.type == 'combobox') {
                var menu = [{ value: '', text: 'All' }];
                var found;
                $.each(rows.rows, function (num_data, row) {
                    found = false;
                    $.each(menu, function (num_menu, item_menu) {
                        if (item_menu.text == row[filter.field]) {
                            found = true;
                            return false;
                        }
                    });
                    if (found == false) {
                        menu.push({ value: row[filter.field], text: row[filter.field] });
                    }
                });
                var cc = $(dd).datagrid('getFilterComponent',filter.field);
                if (cc != undefined) {
                    cc.combobox('loadData', menu);
                }
            }
        });
My problem is the getData method return filtered datas, then the first time i open combobox all is right, but the second time (after filering) only 'All' and my selection appears in the combobox!
is-it possible to get all datas (filtered and not filtered) to correctly fill my combobox?

Logged
jarry
Administrator
Hero Member
*****
Posts: 2300


View Profile Email
« Reply #1 on: September 18, 2015, 01:00:51 AM »

Please try the code below to get the datagrid data.
Code:
var dg = $(dd);
var state = dg.data('datagrid');
var rows = state.filterSource || state.data;
Logged
Fabrice
Jr. Member
**
Posts: 62


View Profile
« Reply #2 on: September 18, 2015, 06:22:03 AM »

Perfect, thx!
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!