In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail what Ext.data.Record is in Ext.js4.2.1. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Ext.data.Record is an object with an internal data type set, and it is the most basic component of Ext.data.Store. If you think of Ext.data.Store as a two-dimensional table, each row of it corresponds to an instance of Ext.data.Record.
The main function of Ext.data.Record is to save data and record the status of changes when the internal data changes. It can also retain the original values before the changes.
When we use Ext.data.Record, we usually start with the create () function, first creating a custom Record type with the create () function, as shown in the following code:
Var PersonRecord = Ext.data.Record.create ([
{name: 'name', type:' string'}
{name: 'sex', type:' int'}
])
PersonRecord is the new type we defined, including name of string type and sex of integer type, and then we use the new keyword to create an instance of PersonRecord, as shown in the following code:
Var boy = new PersonRecord ({
Name: 'boy'
Sex: 0
});
When you create an object, you can assign an initial value to the object directly through the constructor, and assign a 'boy' value to name,0 and a value to sex.
Now that we have an instance of PersonRecord, boy, how can we get its properties? You can get the data for the name attribute in boy in all three ways, as shown in the following code:
Alert (boy.data.name)
Alert (boy.data ['name'])
Alert (boy.get ('name'))
This involves the data property of Ext.data.Record, which is a common property defined in Ext.data.Record and is used to hold all data for the current record object. It is a JSON object from which you can get the data you need. You can easily get the specified attribute from the data property through the get () function of Ext.data.Record.
If we need to modify the data in boy, do not manipulate data directly in the following way, as shown in the following code:
Boy.data.name = 'boy name'
Boy.data ['name'] =' boy name'
Instead, use the set () function, as shown in the following code:
Boy.set ('name',' body name')
The set () function determines whether the value of the property has changed. If so, set the dirty property of the current object to true, and put the original value before the modification into the
Modified object for use by other functions. If you directly manipulate the values in data, record will not be able to record changes to attribute data.
After the attribute data of Record has been modified, we can perform the following operations.
Commit () (submit): the effect of this function is to set dirty to false and delete the original data saved in modified.
Reject () (undo): the effect of this function is to restore the modified attribute values in data to the original data saved in modified, then set dirty to false, and delete the modified object that holds the original data.
GetChanges () gets the modified part: this function puts the modified properties and data in data into a JSON object and returns. For example, in the example above, getChanges () returns a result of {name:'body name'}.
We can also call isModified () to determine whether the data in the current record has been modified.
Ext.data.Record also provides a function copy () to copy the record instance.
Var copyBoy = boy.copy ()
This gives us a copy of boy that contains boy's data data, but the copy () function does not copy additional property values such as dirty and modified.
This is the end of this article on "what is Ext.data.Record in Ext.js4.2.1?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.