Jqwidgets.js:
is a full-featured framework with professional, tactile jquery plugins, themes, input validation, drag-and-drop plugins, data adapters, built-in Wai-aria (accessible Web apps) accessibility, internationalization, and MVVM mode support. Jqwidgets provides a comprehensive solution for building professional websites and developing mobile applications. It is based entirely on open standards and technologies such as HTML5, CSS, JavaScript, and jquery. Jqwidgets enables responsive web development to help you create apps and websites that look beautiful on desktops, tablets, and smartphones.
Whether it is aesthetic or functional than Easyui, code open source usage charges.
SyntacticSugar.dll:
Full-featured a tool class library that includes validation, generalized extension functions, type conversions, file uploads, and a large number of C # syntax sugars.
Source Address: Https://github.com/sunkaixuan/SyntacticSugar
SqlSugar.dll:
is a lightweight, high-performance, easy-to-use ORM framework based on MSSQL
Tutorials and source code: http://www.cnblogs.com/sunkaixuan/p/4649904.html
JQWidgetsSugar.dll (The focus of this post)
The Jqwidgets.js-based C # wrapper class library, which currently only completes the grid section, and all my git projects will be continuously updated in future project development
:
C # code
Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.Mvc;using SqlSugar ; using dal;using jqwidgetssugar;using models;using syntacticsugar;namespace netjqwidgets.controllers{public class Gri Dcontroller:controller {public ActionResult Index () {var ADP = new Griddataadaptersource () ; Adp.url = "/grid/data"; var gc = new Gridconfig (); Gc.gridbuttons = new List<gridbutton> () {new Gridbutton () {click= "add", Name= "AddButton", Icon= "Jqx-icon-plus", title= "add"}, new Gridbutton () {click= "edit", name= "Editbutton", icon= "Jqx-icon-edit", title= "Edit"}, new Gridbutton () {click= "del", Name= "Delbutton", icon= "Jqx-icon-delete", title= "Delete"} }; Gc.pagesize = 20; Gc.width = "80%"; Gc.columns = new List<gridcolumn> () {new GridColumn () {text= "number", datafield= "id", width= "40px",Cellsalign=aligntype.left,datatype=datatype.dataint}, new GridColumn () {text= "name", datafield= "name", cells Align=aligntype.left,datatype=datatype.datastring}, new GridColumn () {text= "product name", datafield= "ProductName", Cellsalign=aligntype.left,datatype=datatype.datastring}, new GridColumn () {text= "quantity", datafield= "Quantity", Cellsalign=aligntype.right, Datatype=datatype.dataint}, New GridColumn () {text= "creation time", datafield= "date", Cellsformat= "Yyyy-mm-dd", Cellsalign=aligntype.right, Datatype=datatype.datadate}}; var Grid = Jqxgrid.bindgrid ("#netgrid", ADP, GC); Viewbag.validationbind = Validationsugar.getbindscript ("Validate_key_grid_index"); return View (GRID); } [Httpdelete] public jsonresult Del (int id) {using (Sqlsugarclient db = Sugardao.getinst Ance ()) {actionresultmodel<string> model = new ACtionresultmodel<string> (); model.issuccess = db. Delete<gridtable> (ID); Model.respnseinfo = model.issuccess? "Delete succeeded": "Delete Failed"; return Json (model); }} [HttpPost] public jsonresult Add (gridtable gt) {using (Sqlsugarclient db = Sug Ardao.getinstance ()) {string message = string. Empty; var isValid = validationsugar.postvalidation ("Validate_key_grid_index", out message); Actionresultmodel<string> model = new actionresultmodel<string> (); if (isValid)//Background Verify data integrity {model.issuccess = db. Insert (GT)! = DBNull.Value; Model.respnseinfo = model.issuccess? "Add Success": "Add Failed"; } else {model.issuccess = false; Model.respnseinfo = message; } return Json (model); }} [Httpput] public jsonresult Edit (gridtable gt) {using (Sqlsugarclient db = Sugardao.getinstance ()) {actionresultmodel<string> model = new Actionresultmodel<stri Ng> (); String message = String. Empty; var isValid = validationsugar.postvalidation ("Validate_key_grid_index", out message); if (isValid)//Background Verify data integrity {model.issuccess = db. Update<gridtable> (GT, it = It.id = = gt.id); Model.respnseinfo = model.issuccess? "Edit succeeded": "Edit Failed"; } else {model.issuccess = false; Model.respnseinfo = message; } return Json (model); }} [OutputCache (Duration = 0)] public jsonresult Data (gridsearchparams pars) {USI Ng (sqlsugarclient db = Sugardao.getinstance ()){if (Pars.sortdatafield = = null) {//default by id descending Pars.sortdatafield = "id"; Pars.sortorder = "desc"; } sqlable sable = db. Sqlable (). Form<gridtable> ("G");//Sqlable object of query table var model = jqxgrid.getwidgetssource<models.gridtable> (SAB Le, pars);//Automatically query the return Json (model, Jsonrequestbehavior.allowget) according to the grid parameters; } } }}
Razor View
@{viewbag.title = "Index"; Layout = "~/views/shared/_layout.cshtml";} @using jqwidgetssugar@section head{<script src= "/content/my97datepickerbeta/my97datepicker/wdatepicker.js" type = "Text/javascript" ></script> <link href= "/content/my97datepickerbeta/my97datepicker/skin/ Wdatepicker.css "rel=" stylesheet "type=" Text/css "/> <script src="/content/jquery-validation-1.13.1/dist/j Query.validate.min.js "type=" Text/javascript "></script> <link href="/content/jquery-validation-1.13.1 /validation.sugar.css "rel=" stylesheet "type=" Text/css "/> <script src="/content/jquery-validation-1.13.1/ Validation.sugar.js "type=" Text/javascript "></script> <script type=" Text/javascript ">//Add function Add (Row) {Save (row, true); }//Edit function edit (row) {Save (row, false); }//delete function del (row) {if (row = = null) {Jqxalert (' Please select a record! ')} else {Jqxdelete ({gridselector: "#netgrid", url: "/grid/del", Data: {id:row.id}}); }} function save (row, Isadd) {var isedit =!isadd; if (Isedit) {if (row = = null) {Jqxalert (' Please select a record! ') return; }}//Popup box Jqxwindow ("#editbox", Isadd? " Add ":" Edit ",", "Auto"); Beautify button $ ("#editbox button"). Jqxbutton (); Cancels the event $ (' #cancel '). Unbind (); $ (' #cancel '). On (' click ', Function (e) {$ ("#editbox"). Jqxwindow ("Close")}); if (Isadd) {//empties the form $ ("#frmtable"). Formclear (); } else {//-Date Row.date = $.convert.todate (row.date, "YYYY-MM-DD")//via JSON AutoFill forms, or self-implemented $ ("#frmtable"). Formfill ({data:row})}//OK Event $ (' #save '). Unbind (); $ (' #save '). On (' click ', Function (e) {factory.ajaxsubmit () (function () {var) url = isadd? "/grid/add": "/grid/edit"; var type = Isadd? "POST": "Put"; $ ("#frmtable"). Ajaxsubmit ({url:url, Type:type, suc Cess:function (msg) {if (msg.issuccess = = False) {Jqxalert (ms G.respnseinfo); } $ ("#netgrid"). Jqxdatatable (' Updatebounddata '); $ ("#editbox"). Jqxwindow ("Close")}, Error:function (msg) {Console.log ( msg); } }) }); }); }//binding validation $ (function () {WindoW.factory = new Validatefactory ($ ("form"), " @Html. Raw (Model)}<div id= "Netgrid" ></div><div id= "editbox" class= "Hide" > <div C lass= "Savetable" > <form id= "frmtable" class= "form" > <table style= "table-layout:fixed; Border-style:none; " > <tr> <td align= "right" > Name: </td> <TD align= "Left" > <input id= "id" name= "id" type= "hidden" value= "0"/> <input id= "name" name= "name" type= "text"/> </td> </tr> < ;tr> <td align= "right" > Product Name: </td> <TD A Lign= "Left" > <input id= "ProductName" name= "ProductName" type= "text"/> </td> </tr> <tr> <td align= "right" > Quantity: </td> <td align= "left" > <input id= "Quantity" name = "Quantity" type= "text"/> </td> </tr> <tr> <t D align= "Right" > Time: </td> <td align= "left" > <input id= "Date" class= "Wdate" onclick= "Wdatepicker ()" Name= "date" type= "text"/> </td> </tr> <tr> <td> </td> <td> <br/> <button id= "Save" type= "button" > Save </b utton> <button style= "margin-left:5px;" type= "button" id= "Cancel" > Cancel & Lt;/button> </td> </tr> </table> </form> </div></div> @Html. Raw (V Iewbag.validationbind)
Examples are not very difficult, that is, the most basic increase, deletion, investigation, change.
Although the function is simple but also takes into account a lot of problems such as: Front end plus the back end of two-way verification, code extensibility, Syntax concise, exception processing.
Demo:https://github.com/sunkaixuan/jqwidgetssugar
The sqlsugar+syntacticsugar+jqwidgetssugar+jqwidgets of the ASP. NET MVC Rapid Development Framework