HTML5¼¼Êõ

Ç°¶ËÓÃDatatablesÖÆ×÷°üº¬ËÑË÷¡¢×Ô¶¯·ÖÒ³¡¢°´ÁÐÅÅÐò¡¢Çл»ÏÔʾÌõÊý¡¢´òÓ¡ÒÔ¼°¶àÖÖÎļþ¸ñʽ±£´æµÈ¹¦ÄܵÄDemo -

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2017-08-10 14:00 ÎÒÒªÆÀÂÛ( )

Ò»¡¢±³¾° ÏîÄ¿ÀïÃæÓиö±í¸ñÄ£¿é£¬ÒªÌṩ±í¸ñµÄ¹ýÂË¡¢ÅÅÐò¡¢·ÖÒ³¡¢±à¼­¡¢´òÓ¡µÈ¹¦ÄÜ£»ÔÚÍøÉÏÕÒÁ˲»Éٿؼþ£¬ÆäÖÐSpreadJSÕâ¸ö´¿Ç°¶Ë±í¸ñ¿Ø¼þ»ù±¾ÉÏ¿ÉÒÔʵÏÖexcelµÄËùÓй¦ÄÜ£¬ÍêÃÀÂú×ãÒªÇ󣬲»¹ýÊÇÊÕ·ÑÁ˵ģ¬Ö»ÄÜ×÷°Õ£¬ºóÀ´·¢ÏÖDatatablesÆäʵҲ²»´í£¬À©Õ¹¹¦ÄÜ

Ò»¡¢±³¾°

¡¡¡¡ÏîÄ¿ÀïÃæÓиö±í¸ñÄ£¿é£¬ÒªÌṩ±í¸ñµÄ¹ýÂË¡¢ÅÅÐò¡¢·ÖÒ³¡¢±à¼­¡¢´òÓ¡µÈ¹¦ÄÜ£»ÔÚÍøÉÏÕÒÁ˲»Éٿؼþ£¬ÆäÖÐSpreadJSÕâ¸ö´¿Ç°¶Ë±í¸ñ¿Ø¼þ»ù±¾ÉÏ¿ÉÒÔʵÏÖexcelµÄËùÓй¦ÄÜ£¬ÍêÃÀÂú×ãÒªÇ󣬲»¹ýÊÇÊÕ·ÑÁ˵ģ¬Ö»ÄÜ×÷°Õ£¬ºóÀ´·¢ÏÖDatatablesÆäʵҲ²»´í£¬À©Õ¹¹¦Äܶ࣬¶øÇÒ×Ô¼ºÒ²¿ÉÒÔÁíÍâÔÚдһЩ¹¦ÄܽøÈ¥¡£DatatablesµÄÎĵµ¹ÙÍøÉÏÃæÓУ¬¸÷ÖÖÓ÷¨µÄÀý×ÓÒ²ºÜ¶à£º

¡¡¡¡×Ðϸ²éÕÒ×Ü»áÓÐÄãÏëÒªµÄ¡£

¶þ¡¢»ù´¡Ó÷¨

¡¡¡¡ÒýÈëjquery¡¢dataTablesµÄjsÓëcss£¬È»ºó³õʼ»¯Ò»¸ötable±êÇ©¾Í¿ÉÒÔÁË¡£

$(document).ready(function() { $().DataTable(); });

¡¡¡¡ÖÁÓÚ±í¸ñÖеÄÊý¾ÝÓжàÖÖ·½Ê½Ìí¼Ó½øÈ¥£¬±ÈÈç<table>±êÇ©ÀïÃæ±¾À´¾ÍÒѾ­°üº¬ÁËËùÓеÄÊý¾Ý£¬»òÕßͨ¹ýjs¶¨ÒåµÄÊý¾ÝÒÔ¼°Í¨¹ýajax´Óºǫ́»ñÈ¡µÄÊý¾Ý£º

Column 1Column 2Column 3Column 4]]; ).DataTable( 17 data:data );

¡¡¡¡ÕâЩ¶¼±È½Ï¼òµ¥£¬²»¹ýÌí¼ÓÀ©Õ¹¹¦ÄÜ»òÕß½áºÏbootstrapÑùʽ£¬»áÓÐÒ»µãµãÂé·³£¬²»¹ý¶àÊÔÒ»ÏÂÎĵµ£¬Ò²ºÜ¼òµ¥ÁË£¬ÕâÀïÖ÷ÒªÊÇ°ÑʵÏÖ±êÌâËù˵µÄ¹¦ÄÜ£¬ÐèÒªÒýÈëµÄÎļþÁгöÀ´Ò»Ï£¬±ÜÃâ²»±ØÒªµÄÂé·³

¡¡¡¡ÕâÀïÃæÓÐЩÎļþÊÇdataTables°üÀïÃæûÓеÄÐèÒªµ¥¶ÀÈ¥ÏÂÔØ£¬pdfmakeºÍJSZip¡£

¡¡¡¡°´Å¥µÄ³õʼ»¯£º

var table = $('#example').DataTable({ //ajax: 'server/data', data: data, buttons: [{ extend: 'copy', className: 'btn btn-default', //Ìí¼Ó¶îÍâµÄÑùʽ text:'<span></span>' //×ÖÌåͼ±ê }, { extend: 'csv', className: 'btn btn-default', text:'<span></span>' }, { extend: 'excel', className: 'btn btn-default', text:'<span></span>' }, { extend: 'pdf', className: 'btn btn-default', text:'<span></span>' }, { extend: 'print', className: 'btn btn-default', text:'<span></span>' }], });
table.buttons().container().appendTo($(
'.buttons')); //°Ñ°´Å¥Ìí¼Óµ½Ö¸¶¨µÄÈÝÆ÷ÀïÃæ

¡¡¡¡ÁíÍâÓÐÒ»µã¾ÍÊDZí¸ñÖеÄÊý¾ÝÊDz»¿É±à¼­µÄ£¬ÎÒ¾ÍдÁËÒ»¸öµ¥»÷ij¸öµ¥Ôª¸ñ£¬½«Æä±ä³ÉÒ»¸öÊäÈë¿ò£¬Íâ±í¿´À´Ö»ÊǶàÁËÒ»¸ö¹â±ê£¬ÀàËÆexcelµÄ±à¼­Ð§¹û£¬ÊäÈë¿ò»ñµÃ½¹µã£¬¹â±êÔÚÎÄ×ÖµÄβ²¿´úÂë·îÉÏ

/** * ÊäÈë¿ò»ñµÃ½¹µãºó£¬¹â±êÔÚÎÄ×Ö×îºóÃæ * @param {[type]} position [description] * @return {[type]} [description] */ $.fn.setCursorPosition = function(position) { if (this.lengh == 0) return this; return $(this).setSelection(position, position); } $.fn.setSelection = function(selectionStart, selectionEnd) { if (this.lengh == 0) return this; input = this[0]; if (input.createTextRange) { var range = input.createTextRange(); range.collapse(true); range.moveEnd('character', selectionEnd); range.moveStart('character', selectionStart); range.select(); } else if (input.setSelectionRange) { input.focus(); input.setSelectionRange(selectionStart, selectionEnd); } return this; } $.fn.focusEnd = function() { this.setCursorPosition(this.val().length); }

¡¡¡¡Ö±½Óµ÷ÓþͿÉÒÔÁË£º$('input').focusEnd()£»ÁíÍ⸽ÉϽçÃæͼƬ£º

 

¡¡¡¡

¡¡

1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

Ïà¹ØÎÄÕÂ
  • ÎóÈëÇ°¶ËÈýÄ꣬һ¸öÎÄ¿ÆÉúµÄ¶À°×£¨ÖÕ½áƪ£© - ÈòÍÁÉÙÄê

    ÎóÈëÇ°¶ËÈýÄ꣬һ¸öÎÄ¿ÆÉúµÄ¶À°×£¨ÖÕ½áƪ£© - ÈòÍÁÉÙÄê

    2017-07-31 18:02

  • html5¶¯»­Ö®µÈ´ý¼ÓÔض¯»­ - è-Ç°¶Ë֮·

    html5¶¯»­Ö®µÈ´ý¼ÓÔض¯»­ - è-Ç°¶Ë֮·

    2017-07-28 10:02

  • ÎóÈëÇ°¶ËÈýÄ꣬һ¸öÎÄ¿ÆÉúµÄ¶À°×£¨ÉÏ£© - ÈòÍÁÉÙÄê

    ÎóÈëÇ°¶ËÈýÄ꣬һ¸öÎÄ¿ÆÉúµÄ¶À°×£¨ÉÏ£© - ÈòÍÁÉÙÄê

    2017-07-21 17:01

  • Ç°¶ËͨÓÿò¼Ü¿ÉÐÐÐÔÑо¿±¨¸æÖ®µ¯´° - Äã²Â²Â¿´

    Ç°¶ËͨÓÿò¼Ü¿ÉÐÐÐÔÑо¿±¨¸æÖ®µ¯´° - Äã²Â²Â¿´

    2017-07-15 11:01

ÍøÓѵãÆÀ
ó