0

Datatable Search On Enter

Finally !!!!

Reference: jquery - datatables global search on keypress of enter key instead of any key keypress - Stack Overflow

Need to declare function on initComplete event. And use search function.

Datatable version 1.11.

$(function() {
    var  table = $('#DataTable1').DataTable({
            proccessing: true,
            searching: true,
            paging: true,
            serverSide: true,
            initComplete: function() {
                $('.dataTables_filter input').unbind();
                $('.dataTables_filter input').bind('keyup', function(e){
                    var code = e.keyCode || e.which;
                    if (code == 13) {
                        table.search(this.value).draw();
                    }
                });
            },
            ajax: {
            url: '@Url.Action("Paginacao")',
            type: 'POST'
        },
        language: {
            url: '/plugins/datatables/lang/Portuguese-Brasil.json'
        },
        columns:
        [
                { "data": "id", visible: false },
                { "data": "nome", "autoWidth": true },
                { "data": "cnpj", "autoWidth": true },
            {
                "render": function(data, type, full, meta) {
                    return '<a href=@Url.Action("Editar", "Usuario")?id='+full.id+'><b><i class=\"fa fa-edit bigfonts\"></i> Editar</b></a>';
                }
            }
        ]
    });

});
0

PHP - Access Object Attributes Dynamically

I want to access object attributes with child objects dynamically just by specifying the attribute in a string variable. 

$book->category->name


$attr="category->name";
$book=\App\Models\Book::find(2);
echo $book->$attr;

Result : null

Solution :

$attr="category->name";
$book=\App\Models\Book::find(2);
$parts=explode("->",$attr);
$h=$book;
foreach($parts as $p){
    $h=$h->$p;
}
echo $h;

Result : book category name



0

Using Docker Git Client

I've got a situation where the git client is not allowed to be installed on the production server (due to strict user policies) but I still want to use git without having to install the git client.

Finally, I found a solution using docker. (For this test I used Docker Desktop on Windows 11).

To clone a repository, just use the instructions below.


  docker run -ti  -v e:\repo\project1:/git alpine/git clone https://gitlab.com/test/project1.git ./

Need to map the volume (on my windows folder) to /git (in docker) and clone the repository to the current folder (./).

Then, git started cloning the repository.

To pull changes :


  docker run -ti --rm -v e:\repo\project1:/git alpine/git pull

 
Copyright © peyotest