EasyUI Forum
September 14, 2025, 06:12:03 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: dynamically load a databox editor for an editable row in a datagrid  (Read 8292 times)
joe
Newbie
*
Posts: 33


View Profile Email
« on: July 23, 2015, 03:19:23 PM »

I want to know if I can stop a datebox editor (or any editor) from loading in a cell on the onBeforeEdit event? Thanks

code for the datagrid:

    $('#dg').edatagrid({
            url: '...url',
            onBeforeLoad: function (param) {
                param.f = $('#dgFilter1').combobox('getValue');
            },
            nowrap: false,
            view: groupview,
            groupField: 'fieldname',
            groupFormatter: function (value, rows) {
                return value + ' :: ' + rows[0].ActivityName;
            },
            onBeforeEdit: function (index, row) {
                var ed = $(this).datagrid('getEditor', { index: index, field: 'fieldname' });
                if(some condition){
                    //stop editor from loading
                }                
            }
        });

HTML for the datagrid:

<table id="dg" title="Name" style="height:300px"  
            toolbar="#toolbar"
            rownumbers="false" singleSelect="true" striped="false" remoteSort="false">  
            <thead>  
                <tr>  
                    <th data-options="field:'Action',width:30" formatter="(function(value, row, index){ return rowAction(row); })">&nbsp;</th>
                    <th data-options="field:'fieldName1',width:175" >Task</th>
                    <th data-options="field:'fieldName1',width:100,editor:{type:'datebox',options:{height:'auto',onSelect: function(date){alert(date.getFullYear()+':'+(date.getMonth()+1)+':'+date.getDate());}}}">Start Date</th>
                    <th data-options="field:'fieldName1',width:100,editor:{type:'datebox',options:{height:'auto'}}">End Date</th>
                    <th data-options="field:'fieldName1',width:100,editor:{type:'datebox',options:{height:'auto'}}">Actual End Date</th>
                    <th data-options="field:'fieldName1',width:100,editor:{type:'datebox',options:{height:'auto'}}">Completion Date</th>
                    <th data-options="field:'fieldName1',width:50" formatter="(function(value, row, index){ return format(row); })" sortable="true">Type</th>
                    <th field="Niente" width="500">&nbsp;</th>
                </tr>  
            </thead>  
        </table>
 
« Last Edit: July 23, 2015, 03:28:44 PM by joe » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: July 23, 2015, 07:26:51 PM »

To disable the editor before editing a row, please set the 'editor' property of the special column to null.
Code:
$('#dg').datagrid({
onBeforeEdit:function(index,row){
var col = $(this).datagrid('getColumnOption', 'fieldname');
col.editor = null;
}
})
Logged
joe
Newbie
*
Posts: 33


View Profile Email
« Reply #2 on: July 23, 2015, 07:58:25 PM »

Thanks stworthy... 
« Last Edit: July 23, 2015, 08:09:51 PM by joe » 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!