ASP. NET-FineUI development practices-16 (I), asp.net-fineui-16

Source: Internet
Author: User

ASP. NET-FineUI development practices-16 (I), asp.net-fineui-16

It is also a basic thing. No events are selected for the grid, and an event is added, in addition to the need to copy and paste it.RecommendationThat!

Step 1: The principle event is triggered and the method is implemented. For all-selected events, there are two modes to be triggered: one is triggered by native extjs, and extjs does not have all-selected events, the normal idea is that the selected row is triggered when it is equal to all rows. This method sounds disgusting, so it still gives up. Simply writing is the second method directly triggered by clicking, click Select All to trigger the Select All event. So here we write it out, it is nothing more than getting element F12. What we operate on is the difference between this div idea and the selected style. In this way, the event is written.
1 $('#Grid1').find('.x-column-header.x-column-header-checkbox').on('click', function () {});
The method is sending back. Here we want to trigger the cs event writing method, not the PageManager of sending back, but the Custom Event of sending back. The core is the parameter of _ doPostBack, what kind of parameters can trigger cs events instead of making no sense? Here I have referred to the existing event rowselect event, and now I have used the method that senior programmers can use -- copy! Step 2: The FineUI-triggered event is based on js sending back. How is rowselect triggered? Right-click the event and check the source code to find two parameters for listeners to listen to select: _ doPostBack, one is triggered by the Grid1 control with ID = Grid1, and the other is interesting. The idea is to write the dead RowSelect $ and the index parameter is the first line, rowSelect $ is used to notify the background that the row selection event is triggered, so we can locate Gird. cs, find row RowSelect $ 3,218th with a segment
1             if (EnableRowSelectEvent)2             {3                 string validateScript = "var args='RowSelect$'+index;";4                 validateScript += GetPostBackEventReference("#RowSelect#").Replace("'#RowSelect#'", "args");5                 string rowSelectScript = JsHelper.GetFunction(validateScript, "model", "record", "index"); //String.Format("function(model,rowIndex){{{0}}}", validateScript);6                 selectOB.Listeners.AddProperty("select", rowSelectScript, true);7             }

You can see that the js Code that triggers the select statement is output in this way. Click query and find another

1             else if (eventArgument.StartsWith("RowSelect$"))2             {3                 string[] commandArgs = eventArgument.Split('$');4                 if (commandArgs.Length == 2)5                 {6                     OnRowSelect(new GridRowSelectEventArgs(Convert.ToInt32(commandArgs[1])));7                 }8             }
OnRowSelect indicates that the parameter RowSelect $ from _ doPostBack is intercepted here, and its rewriting can be triggered in cs after the event is written. Need Analysis? No. copy and paste the file directly.
1             else if (eventArgument.StartsWith("RowAllSelect$"))2             {3                 string[] commandArgs = eventArgument.Split('$');4                 if (commandArgs.Length == 2)5                 {6                     OnRowAllSelect(new GridRowAllSelectEventArgs(bool.Parse(commandArgs[1].ToString())));7                 }8             }
Changed to RowAllSelect $. If this is passed to me at the front end, it indicates that the OnRowAllSelect row select event of cs is triggered. Why is OnRowAllSelect (new GridRowAllSelectEventArgs (bool. parse (commandArgs [1]. toString (); will this sentence have wavy lines? This method is not available! Replace OnRowSelect with OnRowAllSelect to find OnRowSelect.
1 # region OnRowAllSelect 2 private static readonly object _ rowAllSelectHandlerKey = new object (); 3 /// <summary> 4 // All selected tasks in the header (EnableRowAllSelect must be enabled) 5 /// </summary> 6 [Category (CategoryName. ACTION)] 7 [Description ("EnableRowAllSelect)"] 8 public event EventHandler <GridRowAllSelectEventArgs> RowAllSelect 9 {10 add11 {12 Events. addHandler (_ rowAllSelectHandlerKey, value); 13} 14 remove15 {16 Events. removeHandler (_ rowAllSelectHandlerKey, value ); 17} 18} 19 // <summary> 20 // Trigger release selected event 21 /// </summary> 22 // <param name = "e"> event parameter </param> 23 protected virtual void OnRowAllSelect (GridRowAllSelectEventArgs e) 24 {25 EventHandler <GridRowAllSelectEventArgs> handler = Events [_ rowAllSelectHandlerKey] as EventHandler <GridRowAllSelectEventArgs>; 26 if (handler! = Null) 27 {28 handler (this, e); 29} 30} 31 # endregion

Which one has waves? GridRowAllSelectEventArgs is not created. Create a cs file and copy GridRowSelectEventArgs. Do not forget to write your signature.

1 # region Comment 2/* 3 * Project: FineUI 4*5 * FileName: GridRowAllSelectEventArgs. cs 6 * CreatedOn: 7 * CreatedBy: Don't think 935732994@qq.com 8*9*10 * Description: 11 *-> 12*13 * History: 14 *-> 15*16*17*18*19 */20 # endregion21 using System; 22 using System. data; 23 using System. reflection; 24 using System. componentModel; 25 using System. web. UI; 26 namespace FineUI27 {28 /// <summary> 29 // table row selected event parameter 30 /// </summary> 31 public class GridRowAllSelectEventArgs: eventArgs32 {33 private bool _ boolall; 34 /// <summary> 35 // selected 36 /// </summary> 37 public bool boolall38 {39 get {return _ boolall ;} 40 set {_ boolall = value ;} 41} 42 // <summary> 43 // constructor 44 // </summary> 45 // <param name = "rowIndex"> selected status </param> 46 public GridRowAllSelectEventArgs (bool boolall) 47 {48 _ boolall = boolall; 49} 50} 51}

 

In this way, no error should be reported, and the next write will be performed.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.