EasyUI Forum
May 07, 2024, 09:09:22 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: PrePopulate readonly datagrid cell on New record  (Read 1292 times)
kroggity
Newbie
*
Posts: 1


View Profile
« on: May 29, 2022, 09:25:21 AM »

I have a datagrid with a textbox field (Name=Date) set to read-only.  When using the basic CRUD datagrid for editing an existing entry I want to have the Date field set to read only.  When a user clicks on the New button I want to change the value of that reaonly cell to today's date in the popup dialog.  Can anyone recommend how to do this?
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: May 31, 2022, 02:19:07 AM »

Define a form with a readonly datebox component.
Code:
<form id="ff" method="post">
<div style="margin-bottom:20px">
<input class="easyui-textbox" name="name" style="width:100%" data-options="label:'Name:',required:true">
</div>
<div style="margin-bottom:20px">
<input id="birthday" class="easyui-datebox" name="birthday" style="width:100%"
data-options="label:'Birthday:',required:true,readonly:true">
</div>
</form>

After clicking the 'New Button', call this code to load the from with some initialized data and set the datebox component to editable status.
Code:
$('#ff').form('load', {
name: 'myname',
birthday: $.fn.datebox.defaults.formatter(new Date())
});
$('#birthday').datebox('readonly', false)
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!