Sample code download: /201109/yuanma/JQueryElementTest.rar
The content included in this article is as follows:
* Preparation
* Main functions
* Binding fields
* Binding attributes
* Basic settings
* Set paging
* Set fields
* Set the server method to be called
* Request/return data format
* Fill/search
* Update
* Delete
* New
* Row Status Description
* Sort Status Description
* Set Template
* ItemTemplate
* UpdatedItemTemplate/InsertedItemTemplate
* RemovedItemTemplate
* EditItemTemplate
* FilterTemplate/NewItemTemplate
* HeaderTemplate/FooterTemplate/EmptyTemplate
* Special binding
* je-id
* je-
* je-class
* je-checked/selected/readonly
* je-value
* je-
* event
* client method
Repeater example image:
Preparation
Please make sure you have downloaded the latest version of JQueryElement at http://code.google.com/p/zsharedcode/wiki/Download.
Please use the command to quote the following Namespace:
Namespace="zoyobar.shared.panzer.ui.jqueryui"
TagPrefix="je" %>
Namespace="zoyobar.shared.panzer.web.jqueryui"
TagPrefix="je" %>
In addition to the namespace, you also need to reference the jQueryUI script and Styles can be downloaded at http://jqueryui.com, for example:
Main functions
Bind fields
In row templates, you can use the form #{
#{id}
#{realname}
#{age}
< ;/ItemTemplate>
fields can also be bound to tag attributes, such as:
#{id}
#{age}
Bind attribute
in Attributes can be bound to all templates, and the syntax is @{
page @{pageindex}/@{pagecount}, @{itemcount} Article
Basic Settings
The Selector attribute of Repeater is a javascript expression, which will be used as a selector. For writing methods, please refer to http://jquery.com. The element corresponding to the selector Will be presented as the final repeater on the page, example:
/ * ... */
Set the IsVariable attribute to True, then a javascript variable with the same name as ClientID will be generated on the client, example:
Since the ClientID and ID are the same in this page, the repeater can be accessed through studentRepeater. In addition, you can also use the JQueryScript control and use the inline syntax [%id:studentRepeater%] to ensure that pages with different ClientID and ID can also access the repeater. Variable.
Set paging
Set how many pieces of data each page contains through the PageSize property of Repeater. The PageIndex property sets the initial page number. PageIndex defaults to 1.
Set the field
The Field property of Repeater indicates participation in binding. A certain field in the form of a javascript string array, such as: ['id', 'realname', 'age']. If the Field attribute is not set, it will be determined by the first filled data, but this will result in It cannot be created without data.
FilterField represents the field used for search and is also a javascript string array. FilterFieldDefault is the default value when the value of the search field is null or '', example: ['', ' ', 0].
SortField represents the fields involved in sorting, such as: ['id'].
Set the server-side method to be called
You can use Async to set how to call the server-side method, if you are calling WebService , you need to set the MethodName. If it is a general handler such as ordinary ashx, the MethodName is ignored. Example:
UpdateAsync-Url="
UpdateAsync-MethodName="
InsertAsync-Url=""
InsertAsync-MethodName="
RemoveAsync-Url="
RemoveAsync-MethodName="
>
/* ... */
FillAsync-MethodName="Fill"
UpdateAsync-Url="Student.aspx"
UpdateAsync-MethodName="Update"
InsertAsync-Url="Student .aspx"
InsertAsync-MethodName="Insert"
RemoveAsync-Url="Student.aspx"
RemoveAsync-MethodName="Remove"
>
/* ... */
Value="
Default="
Value="
Default="
/* ... */
Value="website "
Default="'-'" />
Value="'#year'"
Default ="2011" />
/* ... */
By adding Parameter, more parameters can be passed. When Name is the parameter name and Type is Expression, the Value contains a javascript expression. Value="website" in the example means taking the value of the javascript variable website , of course, it can also be set as a constant, such as: Value="'www.google.com'" or Value="100". When Type is Selector, the javascript expression in Value will be used as the selector. How to write the selector You can refer to http://jquery.com. The value of the element corresponding to the selector will be used as the value of the parameter. Default is the javascript expression of the default value. When the value of the parameter is null or '', the value in Default will be used. .
Format of request/return data
Fill/search
For filling or search operations, taking WebService as an example, the server will receive the following parameters, pageindex page number, pagesize The number of data items included in each page, and You can receive parameters with the same name as the field or parameters added through Parameter as search conditions, or receive field parameters in the form of
[WebMethod ( )]
public static object
[,
[, string
{
}
[WebMethod ( )]
public static object Fill ( int pageindex, int pagesize
, string realname, int age
, string id_order )
{
}
The server should also return json data in the following format as fill data, where __success defaults to true, itemcount can be omitted, but the pagecount page number will not be calculated.
{
"__success":
"rows":
"itemcount":
}
{
"__success": true,
"rows":
[
{ "id": 1, " realname": "jack", "age": 20 },
{ "id": 2, "realname": "tom", "age": 21 }
],
"itemcount": 120
}
In .NET 4.0 you can use anonymous types to return json, such as:
[WebMethod ( )]
public static object Fill ( /* parameter */ )
{
// ...
List
Update
Delete
Create
Due to space reasons, the above three items cannot be listed in full. If necessary, please refer to: http://code.google.com/p/zsharedcode/wiki/JQueryElementRepeaterDoc
Row status description
In the client's javascript script, there are 4 row statuses, namely unchanged (unchanged), updated (updated), inserted (newly created row), removed (removed row).
Sort status description
In the client's javascript script In , there are 4 sorting states, namely none, no sorting or default sorting, asc ascending order, desc descending order.
Set templates
In the various templates of Repeater, you can set the html code finally displayed by Repeater. These The html code should be complete and legal, and do not use single quotes directly. You can escape the single quotes, otherwise the final display may be abnormal.
ItemTemplate
ItemTemplate is one of the line templates. You can Displays the rows in the unchanged state. If UpdatedItemTemplate or InsertedItemTemplate is not set, then the rows in the updated or inserted status are also displayed in the ItemTemplate. Example:
#{id}
#{realname}
#{age}
/* Edit and delete buttons*/
UpdatedItemTemplate/InsertedItemTemplate
Different from ItemTemplate, UpdatedItemTemplate and InsertedItemTemplate are used to display rows with status updated and inserted respectively. They are mainly used to use different styles to display rows with different statuses, but you can also use simpler je-class to achieve the same effect, example:
< ;UpdatedItemTemplate>
#{id}
#{realname}
#{age}
#{id}
#{realname}
#{age}
RemovedItemTemplate
EditItemTemplate
FilterTemplate/NewItemTemplate
HeaderTemplate/FooterTemplate/EmptyTemplate
The above 4 items cannot be listed in full due to space reasons. If necessary, please refer to: http://code.google.com/p/zsharedcode/wiki/JQueryElementRepeaterDoc
Special Binding
je-id
Use je-id="
je-
Use je-
#{id}
#{realname}
td>
#{age}
Edit span>
delete
#{id}
Cancel
Save
< ;/EditItemTemplate>
It should be noted that togglesort also needs to specify a parameter, which indicates the field to switch the sorting. This field has been set in SortField, for example: je-onclick="togglesort,realname" .
je-class
Use je-class="
Serial number
/* ... */
/* ... */
The syntax of {state} and {sort} needs to be explained here, which are {state[,
je-checked/selected/readonly
Use je-checked="selected" in ItemTemplate with je-onclick="toggleselect" to indicate whether the row is selected. je-selected can be used in EditItemTemplate. select element, example:
je-checked="selected"
je-onclick="toggleselect"
/> #{ id}
je-value
Use je-value=" in FilterTemplate
je-
You can use je-
< ;td>
#{id}
je-datepicker="dateFormat='yy-mm-dd';"
value="#{birthday}" />
je-button="label='Edit';icons={ primary: 'ui-icon-pencil' };"
je-onclick="beginedit"> ;
je-button="label='delete';icons={ primary: 'ui-icon-trash' };"
je-onclick ="remove">
Attribute settings It is consistent with the properties of the jQueryUI plug-in, you can refer to http://jqueryui.com.
Event
All events of Repeater have two parameters, tag and e. tag is the element where the repeater is located, e It contains event-related data.
PreUpdate, Updated are events before and after updating, PreRemove, Removed are events before and after deletion, PreInsert, Inserted are events before and after new creation. The e parameter of these events contains the row attribute, indicating that the relevant operations are currently involved. lines, and the e of Updated, Removed, and Inserted also contains isSuccess, indicating whether the execution is successful, example:
PreUpdate="
function(tag, e){
if(e.row.realname == '' || e.row.age == '' || e.row.birthday == ''){
$('#message').text('Please Fill in the information completely');
return false;
}
}
" PreInsert="
function(tag, e){
if(e.row.realname == '' || e.row.age == '' || e.row.birthday == ''){
$('#message').text('Please fill in the information completely');
return false;
}
}
" PreRemove="
function(tag, e){
if(!confirm('Whether to delete' e.row.realname)){
return false;
}
}
" Updated="
function(tag, e){
$('#message').text('Update' e.row. realname (e.isSuccess ? 'Success' : 'Failure'));
}
" Inserted="
function(tag, e){
$('#message').text( 'New' e.row.realname (e.isSuccess ? 'Success' : 'Failure'));
}
" Removed="
function(tag, e){
$(' #message').text('Delete' e.row.realname (e.isSuccess ? 'Success' : 'Failure'));
}
">
/* ... */
PreFill, Filled events before and after filling, PreExecute, Executed events before and after executing any operation, PreCustom, Customed events before and after executing custom operations, parameter e Contains the command attribute to represent the name of the custom operation. PreSubStep and SubStepped are events before and after executing the distribution operation. The parameter e contains the count attribute to represent the total number of items, and the completed attribute to represent the number of rows that have been processed.
Navigable When the navigation availability changes , the parameter e contains the prev attribute indicating whether there is a previous page, and the next attribute indicating whether there is a next page. Blocked is an event when an operation is blocked.
Client method
This item cannot be listed in full due to space reasons. If necessary, please refer to: http://code.google.com/p/zsharedcode/wiki/JQueryElementRepeaterDoc.
Sample code download: http://zsharedcode.googlecode.com/files/JQueryElementTest.rar.
Actual process demonstration: http://www.tudou.com/programs/view/GQeh0ZIJ0RY/, it is recommended to watch it in full screen.

JavaScript core data types are consistent in browsers and Node.js, but are handled differently from the extra types. 1) The global object is window in the browser and global in Node.js. 2) Node.js' unique Buffer object, used to process binary data. 3) There are also differences in performance and time processing, and the code needs to be adjusted according to the environment.

JavaScriptusestwotypesofcomments:single-line(//)andmulti-line(//).1)Use//forquicknotesorsingle-lineexplanations.2)Use//forlongerexplanationsorcommentingoutblocksofcode.Commentsshouldexplainthe'why',notthe'what',andbeplacedabovetherelevantcodeforclari

The main difference between Python and JavaScript is the type system and application scenarios. 1. Python uses dynamic types, suitable for scientific computing and data analysis. 2. JavaScript adopts weak types and is widely used in front-end and full-stack development. The two have their own advantages in asynchronous programming and performance optimization, and should be decided according to project requirements when choosing.

Whether to choose Python or JavaScript depends on the project type: 1) Choose Python for data science and automation tasks; 2) Choose JavaScript for front-end and full-stack development. Python is favored for its powerful library in data processing and automation, while JavaScript is indispensable for its advantages in web interaction and full-stack development.

Python and JavaScript each have their own advantages, and the choice depends on project needs and personal preferences. 1. Python is easy to learn, with concise syntax, suitable for data science and back-end development, but has a slow execution speed. 2. JavaScript is everywhere in front-end development and has strong asynchronous programming capabilities. Node.js makes it suitable for full-stack development, but the syntax may be complex and error-prone.

JavaScriptisnotbuiltonCorC ;it'saninterpretedlanguagethatrunsonenginesoftenwritteninC .1)JavaScriptwasdesignedasalightweight,interpretedlanguageforwebbrowsers.2)EnginesevolvedfromsimpleinterpreterstoJITcompilers,typicallyinC ,improvingperformance.

JavaScript can be used for front-end and back-end development. The front-end enhances the user experience through DOM operations, and the back-end handles server tasks through Node.js. 1. Front-end example: Change the content of the web page text. 2. Backend example: Create a Node.js server.

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Chinese version
Chinese version, very easy to use
