Extjs 4 grid filter in Asp.net MVC action table query and filtering best resolution Solution

Source: Internet
Author: User

Extjs 4 grid filter in Asp.net MVC action table query and filtering best resolution Solution

Public class extfilterinfo
{
Public String Field {Get; set ;}
Public extfilterdata data {Get; set ;}
}

Public class extfilterdata
{
Public string type {Get; set ;}
Public String Value {Get; set ;}
Public String comparison {Get; set ;}
} Method in action
Public actionresult orderdata (INT start, int limit, string sort, extfilterinfo [] filter)
{
Return view ();
}



Parsing Model Data Binding

Public class extfilterinfomodelbinder: defaultmodelbinder
{
Public override object bindmodel (controllercontext, modelbindingcontext bindingcontext)
{
VaR filter = (extfilterinfo) base. bindmodel (controllercontext, bindingcontext );

VaR field = bindingcontext. valueprovider. getvalue (bindingcontext. modelname + "[field]");
If (field! = NULL)
{
Filter. Field = field. attemptedvalue;
}
VaR type = bindingcontext. valueprovider. getvalue (bindingcontext. modelname + "[data] [type]");
VaR value = bindingcontext. valueprovider. getvalue (bindingcontext. modelname + "[data] [value]");
VaR comparison = bindingcontext. valueprovider. getvalue (bindingcontext. modelname + "[data] [comparison]");
If (filter. Data = NULL)
{
Filter. Data = new extfilterdata ();
}
If (type! = NULL)
{
Filter. Data. type = type. attemptedvalue;
}
If (value! = NULL)
{
Filter. Data. value = value. attemptedvalue;
}
If (comparison! = NULL)
{
Filter. Data. Comparison = comparison. attemptedvalue;
}
Return filter;
}
}
Register registered inApplication_start MethodProtected void application_start ()
{
Arearegistration. registerallareas ();

Registerroutes (routetable. routes );
Modelbinders. binders. Add (typeof (extfilterinfo), new extfilterinfomodelbinder ());
}
Everything is OK !!!



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.