1. Simple gridview list display and gridview list display

Source: Internet
Author: User

1. Simple gridview list display and gridview list display

1. HomeController

1 public ActionResult Index () 2 {3 // return the index bound to models. cshtml 4 return View (NorthwindDataProvider. getDocuments ()); 5} 6 7 // <summary> 8 // return method code 9 // </summary> 10 // <returns> </returns> 11 public ActionResult GridViewPartialView () 12 {13 // partial refresh and bind models14 return PartialView ("GridViewPartialView", NorthwindDataProvider. getDocuments (); 15}

2. view (index. cshtml)

1 <div id="GridViewPartialView">2     @Html.Partial("GridViewPartialView", Model)3 </div>

3. view (GridViewPartialView. cshtml)

1 @ * DXCOMMENT: Configure GridView * @ 2 @ Html. devExpress (). gridView (3 settings => 4 {5 settings. name = "GridView"; 6 settings. callbackRouteValues = new {Controller = "Home", Action = "GridViewPartialView"}; 7 settings. keyFieldName = "entid"; 8 settings. width = System. web. UI. webControls. unit. percentage (100); 9 settings. settingsPager. visible = false; 10 settings. settingsPager. pageSize = 20; 11 settings. settings. verticalScrollBarMode = ScrollBarMode. visible; 12 settings. settings. verticalScrollableHeight = 350; 13 settings. settings. verticalScrollBarStyle = GridViewVerticalScrollBarStyle. virtual; 14 settings. controlStyle. paddings. paddingTop = System. web. UI. webControls. unit. pixel (10); 15 settings. controlStyle. border. borderWidth = System. web. UI. webControls. unit. pixel (0); 16 settings. controlStyle. borderBottom. borderWidth = System. web. UI. webControls. unit. pixel (1); 17 // display the serial number column 18 settings. columns. add (c => 19 {20 c. caption = "no."; 21 c. setDataItemTemplateContent (s => 22 {23 ViewContext. writer. write (s. itemIndex + 1); 24}); 25}); 26 // bind a primary key column and hide the column 27 settings. columns. add ("entid ",""). visible = false; 28 settings. columns. add ("DocumentCode", "document font size"); 29 settings. columns. add ("DocumentName", "document name"); 30 // according to '1' or '0' in the database, the data list is 'administrative 'or 'criminal' 31 settings. columns. add (c => 32 {33 c. fieldName = "DocumentType"; 34 c. caption = "type"; 35 c. setDataItemTemplateContent (s => 36 {37 string showText = s. text; 38 if (s. text = "0") 39 {40 showText = ""; 41} 42 else if (s. text = "1") 43 {44 showText = "criminal"; 45} 46 ViewContext. writer. write (showText); 47}); 48}); 49 // format Date: MVCxGridViewColumnType. dateEdit (year/month/day) 50 settings. columns. add (c => 51 {52 c. fieldName = "DocumentDate"; 53 c. caption = "document date"; 54 c. columnType = MVCxGridViewColumnType. dateEdit; 55 c. settings. autoFilterCondition = AutoFilterCondition. equals; 56}); 57 58 settings. columns. add ("DocumentMemo", "Remarks"); 59 // display the check box column 60 settings. commandColumn. visible = true; 61 settings. commandColumn. showSelectCheckbox = true; 62 }). bind (Model ). getHtml ()
GridView

 

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.