Set default time when interface condition is retrieved

Source: Internet
Author: User

Tag: Set default time setting when interface condition is retrieved default time JS set time Easyui set default time

In the project module, most of the modules have query function, that time query also become a frequent use of things, if the data is large, in the switch interface, will automatically load a data paging display, but is the full table data query, in the execution, performance will become much slower, someone will say that the beginning of the interface, do not load the data , the interface is not very beautiful, because you this interface module, in addition to the search condition box, below the empty, we should at least show some data to others, so that an interface seems to have a normative and full of things.

Then we can give time to retrieve a default time, such as the default is seven days a week, so that the customer in the first module interface switch, read is seven days of data, one has data, and then solve the whole table query work, save the database query time. You do not know, a database of large tables, full table query, that is, a few seconds, words do not say, paste code, this is the JS code, can be used as a reference

/** * @param vtype 1. Seven days ago 2. Today * @param adddaycount get adddaycount days date * @return time format */function getdatestr (Vtype,adddaycou NT) {    var dd = new Date ();    Dd.setdate (Dd.getdate () +adddaycount);    var y = dd.getfullyear ();    var M = Dd.getmonth () +1;//Gets the date of the current month    var d = dd.getdate ();    var H = dd.gethours ();    var m = dd.getminutes ();    var s = dd.getseconds ();    if (VType = = 1) {    return y+ "-" +m+ "-" +D;    } else if (VType = = 2) {    return y+ "-" +m+ "-" +d+ "" +h+ ":" +m+ ":" +s;    }}
The above code is the first time to get, and splicing into the format we want,

function settime () {var today = Getdatestr (2,0); var Sevendayago = Getdatestr (1,-6); $ ("#ZJQGL_startTime"). Val ( sevendayago+ ' 07:00:00 '); $ ("#ZJQGL_endTime"). Val (today);}

This method is to set the default value of two time control, one is the start time, one is the end time, and displayed in the interface, in the interface, the interface will automatically transfer the default time conditions to the background for conditional query.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Set default time when interface condition is retrieved

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.