Solution Idea:
1. Add a "-" + "number in the header for the user to click.
2, the user shrinks and expands the screen the behavior to save in the cookie inside. The page reloads or the user logs on to the system, still remembering the user's behavior.
Advantages: 1, use the form of jquery plug-ins to do, easy to expand. Easy to achieve.
2, stored in the cookie behavior, easy to achieve, reduce workload, users can also receive. If saved in the database, increase the load on the page.
Disadvantage: You cannot use individual behavior for each page: both the contraction and extension of the user are global in the system. And when you log on to another computer, or when you clear the cache, you cannot remember the user's actions.
First use the JS function of the way to achieve. Then change to the jquery plugin: code
Copy Code code as follows:
/*
* Tabletoggle 0.1
* Copyright (c) Novus_lee Http://www.cnblogs.com/novus
* date:2011-12-23
* Hide part of the line's function in the SAGECRM query screen
*/
(function ($) {
$.fn. Tabletoggle = function (options) {
var defaults = {
PLUSSRC: "/upload/201112/20111226224658296.gif",//--[+] Picture
MINUSSRC: "/upload/201112/20111226224658809.gif",
Line:2
}
var options = $.extend (defaults, options);
var flip = 0, i = 0;
This.each (function () {
var $thisTable = $ (this);
var claname = "Btntoggle" + i;
--Add Picture button above the table
var $Title = $thisTable. Parent () parent (). Parent (). Find (TD. Panerepeat ");
$Title. Prepend ("<a href= ' javascript:void (0); ' class= '" + claname + "' style= ' cursor:pointer;padding-right:10px;" ></a> ');
var Trlen = $thisTable. Find ("tr"). Length;
Options.line = (Options.line > Trlen? trlen:options.line);
$Title. Find ("A." + Claname). Click (function () {
$thisTable. Find ("tr:gt (" + Options.line +) "). Toggle (flip++);
if (flip% 2 = 0)
{
$Title. Find ("img[src*= ' Smallplus ']"). attr ("src", options.minussrc);
$.cookie (Claname, "plus");
}
Else
{
$Title. Find ("img[src*= ' Smallminus ']"). attr ("src", options.plussrc);
$.cookie (Claname, "Smallminus");
}
});
if ($.cookie (claname) = "Smallminus" | | | $.cookie (claname) = = "" | | $.cookie (claname) = = null)
{
$ ("A." + Claname). Click ();
}
i++;
});
};
}) (JQuery);
The plugin also invokes a jquery cookie plugin.
Method to invoke:
Copy Code code as follows:
<script type= "Text/javascript" src= ". /scripts/jquery.js "></script>
<script type= "Text/javascript" src= ". /scripts/cookie.js "></script>
<script type= "Text/javascript" src= ". /scripts/toggleblock.js "></script>
<script type= "Text/javascript" >
<!--
$ (function () {
$ ("table.") Content:eq (0) "). Tabletoggle (2);
})
-->
</script>
Effect as shown:
Contraction:
Expand
PS:SAGECRM is what only supports IE7, IE8. So the plugin here doesn't test browser compatibility.