EasyUI Forum
September 14, 2025, 03:12:43 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How can I use linkbutton in datagrid fomatter  (Read 11433 times)
fen9ye
Newbie
*
Posts: 7


View Profile
« on: June 18, 2014, 02:56:02 AM »

<th field="isTaken" width="100" align="center" data-options="
   formatter:takenfomatter
">taken</th>

function takenfomatter(isTaken,row,index){
   var returnStr = "<a href=\"javascript:void(0)\" class='easyui-linkbutton' iconCls=\"icon-add\" onclick=\"javascript:alert('easyui')\">easyui</a>"
        return returnStr;
}
Logged
jarry
Administrator
Hero Member
*****
Posts: 2298


View Profile Email
« Reply #1 on: June 18, 2014, 08:58:10 AM »

The 'formatter' function only returns the formatted string. This function can't create any components automatically. You have to construct them manually. Please try to call .linkbutton(...) when loaded data successfully.
Code:
$('#dg').datagrid({
  onLoadSuccess:function(){
    $(this).datagrid('getPanel').find('a.easyui-linkbutton').linkbutton();
  }
});
Logged
fen9ye
Newbie
*
Posts: 7


View Profile
« Reply #2 on: June 18, 2014, 07:05:03 PM »

A thousand thanks.A new problem rise.I add the onclick function to the linkbutton as follows:
      function abc(isTaken,infoId){
         var index = $('#info_dg').datagrid('getRowIndex',infoId);
         $('#info_dg').datagrid('updateRow',{
            index: index,
            row: {
               isTaken : 1-isTaken
            }
         });
         $('#info_dg').datagrid('refreshRow',index);
      }
(linkbutton's text and icon depends on the isTaken).
After click,the text is correct but the linkbutton disapear.What shouldI do?
« Last Edit: June 18, 2014, 07:07:36 PM by fen9ye » Logged
jarry
Administrator
Hero Member
*****
Posts: 2298


View Profile Email
« Reply #3 on: June 19, 2014, 12:31:43 AM »

After update a row, you need to call .linkbutton() to create the linkbutton again.
Code:
$('#dg').datagrid('getPanel').find('a.easyui-linkbutton').linkbutton();
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!