ASP. Net mvc5 + ef6 + easyUI background management system (81) – data filtering (universal query) example

preface

Listening to the title seems to be a very complex function, but in fact it is very complex. This section will demonstrate how to implement combined query (data filtering) on data

We all know how to filter data in Excel Just like below

It is a parallel relationship. What we need to do now is the same effect. Next, we will use the DataGrid of easyUI as an example to extend it (even other components can be implemented in the same way!)

Realization idea

1. The foreground combines JSON through query

2. Disassemble JSON through reflection in the background

3. Perform combined query

Although it's just 3 o'clock, it's enough for you to write for 3 days and nights

Advantages: it needs to get accurate data from a lot of data. It is usually used when the properties of some commodities are abnormally close

Disadvantages: my implementation method is pseudo query. Please use stored procedures for a large amount of data

Simple understanding

I learned a JS file from the official extension of easyUI, but in fact, there are many bugs in this file. I once thought it was a problem in use, but it is not available at all

So I'll present the whole modified JS code here first

Modified DataGrid filter js

In order to achieve one purpose: enter the data and press enter to query the data.

This extension can integrate 90% of easyUI's form components

1. Time

2. Figures

3. Pull down Combo@R_283_2419 @

4. Password box

wait.......

In fact, only 1,2,3 are used Combx@R_283_2419 @Generally, dynamic data is obtained from the background by Ajax

See the code (I have encapsulated it and can call it as much as I like. If you want to understand it, go to check the code writing method and logic)

The above nonsense has been finished! Let's talk about how to call

Front end implementation

1. Introduce DataGrid filter js

2. Call

Before calling, take a look at the DataGrid we wrote before. This is an ordinary DataGrid

So I just want to tell you that the ID name of my DataGrid is list

Then the effect of the front end will come out! It is so simple because the encapsulated JS has helped us do a lot of work. The results are as follows:

Note: if initcombofilter is Ajax, the fourth parameter can be passed to the URL, and the key values are ID and name respectively

Where: VAR OP = ['equal ',' greater ']; It's a funnel. No matter how much you say, you don't understand it. If you want to have an in-depth understanding, you need to look at the source code

3. Press enter to perform filtering

Carriage return event in the source code

At this point, the call to the front end is over!

Background implementation

Because the front end will pass one more parameter, we need to write one more parameter in the background to accept it. Just modify the previous gridpager and add one more parameter.

So the controller has not changed.

Bll changes are as follows:

Everything else remains the same.

A lot of work has been done in the background. Look at the linqhelper class

Preview effect:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>