Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Coloca no final da __contruct da TPage com TDatagrid, antes de chamar o método "parent::"
- */
- TScript::create("
- var arr = [
- {val : 5, text: '5'},
- {val : 10, text: '10'},
- {val : 20, text: '20'},
- {val : 50, text: '50'},
- {val : 100, text: '100'},
- {val : 500, text: '500'},
- {val : 1000, text: '1000'}
- ];
- var value_selected = 20;
- $('<label style=\"margin-left:10px; padding-left=10px; padding-right:10px; font-size: 12px;\">Qtde por página</label>').appendTo('.panel-footer:first');
- var sel = $('<select id=\"limit_page\">').appendTo('.panel-footer:first');
- $(arr).each(function() {
- sel.append($(\"<option>\").attr('value',this.val).text(this.text));
- });
- if (!!$.cookie('profile_limit_". self::$formName ."_per_page')) {
- var select_actual = $.cookie('profile_limit_". self::$formName ."_per_page');
- $('#limit_page').val(parseInt(select_actual));
- $('#limit_page').change();
- }
- $('#limit_page').on('change', function(){
- value_selected = $(this).val();
- document.cookie=\"profile_limit_". self::$formName ."_per_page = \" + value_selected;
- __adianti_load_page(\"index.php?class=" . __CLASS__ . "&method=onReload\"); /* url para voltar*/
- });
- ");
- /*
- Na onReload, cola em substituição a linha com LIMIT
- */
- $limit = GeneralFunctions::checkCookieForLimit('profile_limit_'. self::$formName .'_per_page');
- /*
- Coloca a função na sua helper de funções gerais
- */
- public static function checkCookieForLimit($cookie_name)
- {
- // if ($cookie_name == 'profile_limit_vendas_per_page') {
- if(isset($_COOKIE[ $cookie_name ])){
- $limit_l = $_COOKIE[ $cookie_name ];;
- if (!is_numeric($limit_l) || $limit_l == 0 ) {
- $limit = 10;
- } else {
- $limit = (int) $limit_l;
- }
- } else {
- $limit = 10;
- }
- $result = $limit;
- // }
- return $result;
- }
Advertisement
Add Comment
Please, Sign In to add comment