Welcome Guest, Not a member yet? Register   Sign In
Flexigrid - Lightweight but rich data grid

[eluser]unexpectedly[/eluser]
[quote author="paulopmx" date="1217136513"]
Actually there is "something simple" via jQuery, its called the process method in the colModel. search it around this threat as i've put a lot of examples on how to use it.
Paulo[/quote]

Hi Paulo, thanks for your time in replying! I did try process method based on the examples I could find, but wasn't able to get it working. I did get solution for onClick() and have moved on past that moment.

[quote author="anakreon" date="1217186012"]
When a user clicks a link, if flexgrid is not constructed, create it.
If flexgrid exists, change the parameters sent to the server.

I know how to acomplish the first part, but do not know how to alter
the paramters.[/quote]

You mean like changing this:
Code:
$("#flex1").flexigrid
(
{
url: 'post2.php',
dataType: 'json',
colModel : [
    {display: 'ISO', name : 'iso', width : 40, sortable : true, align: 'center'},
    {display: 'Name', name : 'name', width : 180, sortable : true, align: 'left'},
    {display: 'Printable Name', name : 'printable_name', width : 120, sortable : true, align: 'left'},
    {display: 'ISO3', name : 'iso3', width : 130, sortable : true, align: 'left', hide: true},
    {display: 'Number Code', name : 'numcode', width : 80, sortable : true, align: 'right'}
    ],
buttons : [
    {name: 'Add', bclass: 'add', onpress : test},
    {name: 'Delete', bclass: 'delete', onpress : test},
    {separator: true}
    ],
searchitems : [
    {display: 'ISO', name : 'iso'},
    {display: 'Name', name : 'name', isdefault: true}
    ],
sortname: "iso",
sortorder: "asc",
usepager: true,
title: 'Countries',
useRp: true,
rp: 15,
showTableToggleBtn: true,
width: 700,
height: 200
}
);

What about your php/asp/perl page rendering the HTML having the ability to dynamically rewrite the above code? I have it with javascript enough times... Smile

[eluser]tof[/eluser]
[quote author="paulopmx" date="1216907081"][quote author="tof" date="1216757662"]hello,
i'm going to use flexigrid for my new programs.
however, i would like to dynamically parse the grid's attributes to add new functions to the grids (printing, csv output, etc).
i've passed the all day trying to get the colModel definition but i didnt succeed.
i want to get the colModel definition, the sortname & sortorder attributes, in javascript, so that i can generate the sql command coresponding to the user choices once he had played with the grid appearance...
maybe someone here can help me ?[/quote]

I actually don't understand why you need the grid's attributes to add new functions of (printing, csv output, etc).

But to get the attributes try this custom api method

Code:
$.fn.flexAttr = function(p) {

        return this.each( function() {
                if (this.grid) return this.p;
            });

    };
[/quote]

Thanks for the answer. i need it because i want to know what columns remains after the user had rearrange his grid, and what is the new sort criteria.
i can parse the DOM generated but i think it would be more accurate to get these informations directly from the attributes of the flexigrid component.

I have try to implement your function but when i call it by : jQuery('#mygrid').flexAttr('title'); i get an [Object] instead of the title attribute of the grid.

[eluser]anakreon[/eluser]
I do not want to change the initilization of flexgrid.
Nor can I have a server side script generate the code.

What I need is after the grid is created and initilized,
when a user clicks some links, change the parameters flexgrid
sends to the server and reload the data.

In pseudocode would be:
function onUserClick(id) {
$('#flexgrid_table').params({category_id: id});
$('#flexgrid_table').reloadData();
}

Is it possible to alter the parameters *after* the grid is created?
Is there a function which would force the component to reload it's data (like the refresh button
the component displayes)?

Thanks for you replay

[eluser]TheJayL[/eluser]
This code chunk was giving me an error in IE6. I commented it out and do not get the error anymore. On top of that, I see no change to the grid, so what exactly does this code segment do??

Code:
else if (!g.colresize) {

                                    /*var nv = $('th:visible',g.hDiv).index(this);
                                    var onl = parseInt($('div:eq('+nv+')',g.cDrag).css('left'));
                                    var nw = parseInt($(g.nBtn).width()) + parseInt($(g.nBtn).css('borderLeftWidth'));
                                    nl = onl - nw + Math.floor(p.cgwidth/2);

                                    $(g.nDiv).hide();$(g.nBtn).hide();

                                    $(g.nBtn).css({'left':nl,top:g.hDiv.offsetTop}).show();

                                    var ndw = parseInt($(g.nDiv).width());

                                    $(g.nDiv).css({top:g.bDiv.offsetTop});

                                    if ((nl+ndw)>$(g.gDiv).width())
                                        $(g.nDiv).css('left',onl-ndw+1);
                                    else
                                        $(g.nDiv).css('left',nl);

                                    if ($(this).hasClass('sorted'))
                                        $(g.nBtn).addClass('srtd');
                                    else
                                        $(g.nBtn).removeClass('srtd');*/

                                    }

[eluser]bao.vu[/eluser]
Hi,
I'm new here and just want to say thank you to Paulo. Secondly, I am trying to make a button that make the list printable, i.e list everything from the query without using pager. I am just wondering how to do that if anyone can help.
Thanks

[eluser]TheJayL[/eluser]
^^^^^^
Make a button just like examples.

It starts a javascript function with ajax to your underlying (php?) page that does the query in the first place. Give the ajax request however some added parameter in the GET like page.php?print=1. Your page should be smart to know to add the limit to the database query only if print doesn't exist or isn't true. This returns to you XML or JSON. From there its just parsing the data. All this is outside the grid's functionality really.

Hope this isn't too obvious and somewhat helpful.

[eluser]bao.vu[/eluser]
Thanks, that works. I clicked on the button and it loads another page with all my data on one table. A problem though, I click print and only one page of the flexigrid is printed. Any idea.

[eluser]TheJayL[/eluser]
When you say one page, you mean one physical page of paper, or do you mean one page like the pager?

If its one page, as in the pager, then the query is still using LIMITED, or it is not using the new data, but the data the list was created with.

[eluser]TheJayL[/eluser]
Thank you poster for pointing out the Memory Leak in IE. My browser was up to 250,000K and didn't realize why my list was so slow.

How do we deal with this leak, or is this something to be fixed in a release?


I tried adding CollectGarbage() to onSuccess() of the list loader but that doesn't seem to help. Grid works great on first instance and slowly gets slower. Despite my wishes I must program for IE so how do I fix this?


Also, I checked FIreFox as well. There is leakage there as well when the user changes the grid without refreshing the page.(using the buttons to navigate list / change the rows per page / quicksearch) Once you do refresh mem leak is still there.

[eluser]bao.vu[/eluser]
[quote author="TheJayL" date="1217288265"]When you say one page, you mean one physical page of paper, or do you mean one page like the pager?

If its one page, as in the pager, then the query is still using LIMITED, or it is not using the new data, but the data the list was created with.[/quote]

One page of the physical paper. All data on my table displays in one page of the grid (I don't have to click next page). But when I print, only the portion that is on the first page printed. I hope I explained that well.




Theme © iAndrew 2016 - Forum software by © MyBB