Ext.net Study notes 17:ext.net Gridpanel Selection

Source: Internet
Author: User

Ext.net Study notes 17:ext.net Gridpanel Selection

Next is another feature of Ext.net's Gridpanel: SELECT.

We have seen how to use the selection function in Gridpanel's first usage, and today we will introduce the selection function of ext.net gridpanel in more detail.

Ext.net Gridpanel selection consists of three species:

    • Rowselectionmodel: Row Selection model
    • Checkboxselectionmodel: Row selection model with check box
    • Cellselectionmodel: Cell selection model

By default, Gridpanel uses Rowselectionmodel to be able to make a single selection, and if you want Gridpanel to be able to do multiple selections, you need to add attributes to the Gridpanel:

<ext:runatIDcolumnlinesWidthHeightmultiselect= "true" >  

Let's take a look at the usage of these three models separately

Rowselectionmodel

The effect is as follows:

Implementation code:

<Selectionmodel>    <ext:runatMode= "Multi" ></ext:  Rowselectionmodel></selectionmodel>        

In the Rowselectionmodel configuration, the properties mode represents the selected type, single, Multi (multiple selection), and simple (easy multiple selection).

The difference between radio and multi-choice is obvious, let's say the difference between multi and simple:

    • Multi: Multiple selection, but you need to use the keyboard CTRL, shift to complete the match. In the actual use of the process you will find that simple mouse click can not achieve multiple selection, you need to press the CTRL key to multiple selection, if you want to select an area, you can press the SHIFT key at the same time.
    • Simple: Multiple selection, do not require CTRL or SHIFT key mates. Multiple selections can be achieved with only a mouse.

Checkboxselectionmodel

Effect

The code is as follows:

<ext:runatModeinjectcheckbox= "1" ></ext:Checkboxselectionmodel >         

The mode attribute is the same as the Mode property in Rowselectionmodel and is not described.

The Injectcheckbox property is used to determine where the checkbox column appears (number of columns), which defaults to 0, starting with the No. 0 column.

Cellselectionmodel

Effect

The code is as follows:

<ext:runat= "Server" ></ext:cellselectionmodel>    

I tried it as if I had to select only one cell.

Check the ExtJS API later found that you really can only select a cell, it also has a mode property, but this property has only one available value: Single.

The client gets the selected value

Because this series is more biased server-side processing, so this place simply say the client gets the value of the method, the code is as follows:

Selectedrows = Grid.getselectionmodel (). GetSelection ();

Grid is our Gridpanel, preferred to get its selection model, after the model, and then from the selection model to get the selected content.

Server-side Gets the selected value

For the server side, we can use the same idea to get the selected value.

VarSelectionmodel = grid. Getselectionmodel ()AsRowselectionmodel;If(SelectionModel.SelectedRows.Count = = 0) {X. Messagebox.alert (Prompted " no row "". Show (); returnstring string. Empty; foreach var item selectionmodel.selectedrows" {ids + =  "," + item. RecordID;} ids = IDs. Trim ( ", '  "hint" , IDS). Show ();                 

Note: If the model associated with the store is not set Idproperty, you will not be able to get RecordID

The above code is for Rowselectionmodel and Checkboxselectionmodel, and if it is cellselectionmodel, we can get the value of the cell, and so on:

Varcellmodel = grid. Getselectionmodel () cellselectionmodel; //Get Records Idvar recordid = CellModel.SelectedCell.RecordID; //gets the cell value cellvalue = CellModel.SelectedCell.Value; //gets the column name var columnname = CellModel.SelectedCell.Name; //gets the column number var columnindex = CellModel.SelectedCell.ColIndex; //get line number rowindex = CellModel.SelectedCell.RowIndex             

OK, the above is about ext.net gridpanel selection content, this article by the Takeoff network original first, please continue to pay attention.

Ext.net Study notes 17:ext.net Gridpanel Selection

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.