EasyUI Forum

General Category => Bug Report => Topic started by: 2plus2 on April 26, 2013, 05:47:45 PM



Title: Checked data not being cleared on grid load...
Post by: 2plus2 on April 26, 2013, 05:47:45 PM
Howdy...

I'm loading a grid with data on demand (via a combination of combobox selections) and the checked status is not being cleared when new data is loaded. My code:

Code:
                    $('#dgExample').datagrid({
                        url: '/admin/ajax.aspx?a=getFiltered&r=' + $('#Some_Id').val() + '&i=' + fooId,
                        onLoadSuccess: function (data) {
                            var stringOfIDs = "";
                            for (i = 0; i < data.rows.length; ++i) {
                                if (data.rows[i]['Selected'] == 1) {
                                    $(this).datagrid('checkRow', i);

                                    if (stringOfIDs.length > 0) { stringOfIDs+= ','; }
                                    stringOfIDs+= data.rows[i]['id'];
                                } else {
                                    $(this).datagrid('uncheckRow', i);
                                }
                            }
                            $('#IDList').val(stringOfIDs);
                        }
                    });

I'm returning "Selected" as a 1/0 in the JSON, and iterating over that checking and unchecking the rows as needed. At first I tried just looking for the "1"s and selecting the rows, but that wasn't unchecking and "existing" rows. Shouldn't the selected/checked state be cleared each time you load data into the data grid?

Also - is there anyway to have the load event look for "Selected" as a name / value pair and check the checkbox automatically ?