EasyUI Forum
May 03, 2024, 10:59:26 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: automatic check/select data in datagrid  (Read 12825 times)
aswzen
Sr. Member
****
Posts: 287


Indonesian

aswzen
View Profile WWW Email
« on: June 02, 2014, 02:59:08 AM »

I think you missed something in datagrid demo...  Cry

How to create a datagrid with some data already checked or selected?

I found method in docs about using selectRow and checkRow..
but it just worked only in client side (checked or selected after datagrid successfully loaded).....

Code:
<table id="package_group_table" class="easyui-datagrid" style="width:250px;height:150px"
                data-options="url:admin/packagegroup/list_package_group_for_checkbox',singleSelect:false">
                        <thead>
                            <tr>
                                <th data-options="field:'PACKAGE_GROUP_ID'">ID</th>
                                <th data-options="field:'PACKAGE_GROUP_ALIAS'">Name</th>
                                <th data-options="field:'CHECKED'"   formatter="formatCheck">Status</th>
                                <th data-options="field:'CHECKED_STATUS',checkbox:true">Ck</th>
                            </tr>
                        </thead>
                    </table>
                    <input type="button" onclick="wawa();" value="tes"></input>
                    <script type="text/javascript">
                        function formatCheck(val,row,idx){
                            if(val+'' == 'true'){
                                $('#package_group_table').datagrid('checkRow', idx);
                            }
                        }
                    </script>

Code above isnt working...
CHECKED field populated with true and false data...
« Last Edit: June 03, 2014, 03:28:50 AM by aswzen » Logged

Regards,
Sigit

- Indonesian jEasyUI Facebook page : https://www.facebook.com/groups/jeasyuiid/
aswzen
Sr. Member
****
Posts: 287


Indonesian

aswzen
View Profile WWW Email
« Reply #1 on: June 03, 2014, 03:29:45 AM »

help please ....
Logged

Regards,
Sigit

- Indonesian jEasyUI Facebook page : https://www.facebook.com/groups/jeasyuiid/
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #2 on: June 03, 2014, 07:50:23 AM »

The 'checkRow' method must be called after loaded data successfully, so please do the checking rows in the 'onLoadSuccess' event.
Code:
<table id="package_group_table" class="easyui-datagrid" style="width:250px;height:150px"
    data-options="url:admin/packagegroup/list_package_group_for_checkbox',singleSelect:false,
    onLoadSuccess:function(){
var rows = $(this).datagrid('getRows');
for(var i=0; i<rows.length; i++){
if (rows[i]['CHECKED']){
$(this).datagrid('checkRow',i);
}
}   
    }
    ">
    <thead>
        <tr>
            <th data-options="field:'PACKAGE_GROUP_ID'">ID</th>
            <th data-options="field:'PACKAGE_GROUP_ALIAS'">Name</th>
            <th data-options="field:'CHECKED'">Status</th>
            <th data-options="field:'CHECKED_STATUS',checkbox:true">Ck</th>
        </tr>
    </thead>
</table>
Logged
ryupanqui
Newbie
*
Posts: 44


View Profile Email
« Reply #3 on: June 03, 2014, 04:01:15 PM »

I would know about this. Why this is not a default behaviour of datagrid? Because I think the problem is that developer will have to repeat this same code  in the 'onLoadSuccess' event of each datagrid. Thanks in advance for your reply!
« Last Edit: June 03, 2014, 04:14:39 PM by ryupanqui » 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!