Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - motoguru

Pages: [1] 2 3
1
Help for ParamQuery Pro / Re: Select with jquery checkboxdropdownlist
« on: April 07, 2014, 09:22:26 pm »
Hello,

Sorry for delay. First of all You have to add normal dropdown list (select) into Your toolbar items:

{
                    type: 'select', style:"width:150px;",cls: "ddClass",
                    options: function (ui) {
                        var CM = ui.colModel;
                        var opts = [];//[{ '': '[ All columns ]' }];
                        for (var i = 0; i < CM.length; i++) {
                            var column = CM[ i ];
                            var obj = {};
                            obj[column.dataIndx] = column.title;
                            opts.push(obj);
                        }
                        return opts;
                    }
                },

Then, just after grid initialization:

$grid= $("#gridContainer").pqGrid(obj);
$toolbar = $grid.find('.pq-toolbar-search');
$toolbar.find(".ddClass").multipleSelect().multipleSelect("checkAll"); //if You want to check all options at start
$grid.pqGrid("refresh");

And to get the selections:

dataIndxs = $toolbar.find(".ddClass").multipleSelect("getSelects");

(returns array)

Remember to include somewhere in Your HTML's head:

<link href="/multiselect/multiple-select.css" rel="stylesheet" />
<script type="text/javascript" src="/multiselect/jquery.multiple.select.js"></script>

Download it here: https://github.com/wenzhixin/multiple-select


2
Hello,

I have a custom float field which contains currency format (eg. as a string '123 921.43 USD'). As it's a number not a string, I want to use custom dataType which is in this example:

 colModel[0].dataType = function (val1,val2) {
                val1 = val1.replace(/ /g, '');
                val1 = val1.replace('USD', '');
                val2 = val2.replace(/ /g, '');
                val2 = val2.replace('USD', '');
                val1 = parseFloat(val1);
                val2 = parseFloat(val2);
                if (val1 > val2) return 1;
                if (val1 < val2) return -1;
                return 0;
            };

And it sorts column fine. But filter treats the column as a string and won't filter it well as a float or using custom coparator as seen above. Is there any chance to take column dataType as a comparator method not as a string in filter? Notice I don't want to make this column "float" first and use column render method later.

Thanks in advance

3
Help for ParamQuery Pro / Re: Select with jquery checkboxdropdownlist
« on: February 28, 2014, 07:49:43 pm »
If somebody is interested, this plugin does it well:

https://github.com/wenzhixin/multiple-select

Thread can be closed.

4
Help for ParamQuery Pro / Select with jquery checkboxdropdownlist
« on: February 28, 2014, 06:58:23 pm »
Hi,

Another question is to apply some modifications to items in toolbar. I tried to use this plugin: https://github.com/scottwb/jquery.ui.dropdownchecklist to change my select in the toolbar (for selecting filter columns - one/selected/all), and the result is empy place instead of my select. This is the select declaration:

 {
                        type: 'select', cls: "filterColumnG",

                        options: function (ui) {
                            var CM = ui.colModel;
                            var opts = [{ '': '[ All columns ]' }];
                            for (var i = 0; i < CM.length; i++) {
                                var column = CM[ i ];
                                var obj = {};
                                obj[column.dataIndx] = column.title;
                                opts.push(obj);
                            }
                            return opts;
                        }
                    },


And, enabling grid and my drop down:

  var $grid = $("#grid").pqGrid(obj);

  $toolbar = $grid.find('.pq-toolbar-search');
  $toolbar.find(".filterColumnG").dropdownchecklist({ firstItemChecksAll: true, });
  $grid.pqGrid('refresh');


[EDIT]
This plugin requires ui.core.js, but when I add it to the head, my grid won't start, I have jQuery UI included after all.

[EDIT 2]
Hold on for a while as I'll try to use another plugin as this one is old. I'll post results.

5
Bug Report / Re: Autofit after refresh data and view
« on: February 28, 2014, 04:20:14 pm »
Okay, thought about it before, but I was in hope there is built in function for it :)

Thanks anyway.

6
This one solved the problem, thank You. [EDIT: contain criteria didn't work because I had problem with filterrender funcition]

If somebody is interested in having regexp hightlited, this is the example of altered filterrender function:

//filterRender to highlight matching cell text.
function filterRender(ui) {
 
    var val = ui.cellData,
        filter = ui.column.filter;

    var valTest = safeToString(val);
    if (valTest.indexOf("<a") != -1 || valTest.indexOf("<img") != -1) {
        return val;
    }

    if (filter && filter.on && filter.value) {
        var condition = filter.condition,
            valUpper = safeToString(val).toUpperCase(),
            txt = filter.value,
            txtUpper = txt.toUpperCase(),
            indx = -1;
        if (condition == "end") {
            indx = valUpper.lastIndexOf(txtUpper);
            //if not at the end
            if (indx + txtUpper.length != valUpper.length) {
                indx = -1;
            }
        }
        else if (condition == "contain") {
            indx = valUpper.indexOf(txtUpper);
        }
        else if (condition == "begin") {
            indx = valUpper.indexOf(txtUpper);
            //if not at the beginning.
            if (indx > 0) {
                indx = -1;
            }
        }
        else if (condition == "regexp") {
            txt = txt.replace("/").split("|");
            val = safeToString(val);
            for (var n in txt) {
                var txtNoRegexp = txt[n];
                txt[n] = new RegExp(txt[n],"ig");
                val = val.replace(txt[n], "<span style='background:yellow;color:#333;'>" + txtNoRegexp + "</span>");
            }
            return val;
        }
        if (indx >= 0) {
            var txt1 = val.substring(0, indx);
            var txt2 = val.substring(indx, indx + txt.length);
            var txt3 = val.substring(indx + txt.length);
            return txt1 + "<span style='background:yellow;color:#333;'>" + txt2 + "</span>" + txt3;
        }
        else {
            return val;
        }
    }
    else {
        return val;
    }
}


safeToString() is the method mentioned above ITT.

7
Bug Report / Re: Autofit after refresh data and view
« on: February 27, 2014, 08:43:43 pm »
So how to get result I want? For example:

I got 8 columns at start. My grid is 800px width, so I want them to be 100px each (and its done by autofit initially). Then, I want to hide 4 of them, so now I have 4 columns. Obviously, when I would start with 4, autofit would make them 200px each. It does "live", but when I bring 4 columns back (to get 8 like before) and do it "live", widths are computed according to screen attached (like randomly?, for example col1: 120px, col2: 200px, col3:200px and so on to fill 800px...). How to bring them back and split 800px ALWAYS equally between columns after show/hide operations (like an old html table width="*" behaviour). Don't know how to explain it in more detailed way to be honest...

8
Bug Report / Re: Autofit after refresh data and view
« on: February 27, 2014, 08:03:20 pm »
Why widths are not computed to proportionally (each equal) fit all the grid width all the time..? I mean why they start proportionally and then, when hidden/shown again they're not proportionally equal, then refresh (f5) and they are equal again? It's a bit strange behaviour. Nothing changed in 2.0.4.

9
Hello there, 2.0.4..

Ok then, I get:

TypeError: cd.indexOf is not a function

if (cd.indexOf(value) != -1) {

pqgrid.dev.js (row 9339)



In

function filterhandler(evt, ui) {

            var $toolbar = $grid.find('.pq-toolbar-search'),
                $value = $toolbar.find(".filterValue"),
                value = $value.val(),
                condition = $toolbar.find(".filterCondition").val(),
                dataIndx = $toolbar.find(".filterColumn").val(),
                filterObject;

            var word = value;
            if (condition == 'regexp') {
                var spl = word.split(" ");
                word = "";
                for (var n in spl) {
                    word += spl[ n ];
                    if (n != spl.length - 1) {
                        word += "|";
                    }
                }
                word = new RegExp(word);
                value = word;
            }

            if (dataIndx == "") {//search through all fields when no field selected.
                filterObject = [];
                var CM = $grid.pqGrid("getColModel");
                for (var i = 0, len = CM.length; i < len; i++) {
                    var dataIndx = CM[ i ].dataIndx;
                    filterObject.push({ dataIndx: dataIndx, condition: condition, value: value });
                }
            }
            else {//search through selected field.
                filterObject = [{ dataIndx: dataIndx, condition: condition, value: value }];
            }
            $grid.pqGrid("filter", {
                oper: 'replace',
                data: filterObject
            });
        }


when using condition "regex". You said my code logic is good before, so any suggestions?

10
Help for ParamQuery Pro / Re: Handle onScrollBottom event?
« on: February 25, 2014, 05:51:49 pm »
Great stuff. Thanks

11
Help for ParamQuery Pro / Handle onScrollBottom event?
« on: February 25, 2014, 02:28:55 am »
Hello again :)

Bored of my questions yet? :)

Is there any method of handling event when user scrolled to the bottom of grid? I want to add some remote data to local data then. (flexheight: false, pagination: disabled, all rows on page, like infinite scroll on free version Demo)

12
Got it, thanks :)

13
Hmm, according to my filter code (which we used in this thread before):

     function filterhandler(evt, ui) {

            var $toolbar = $grid.find('.pq-toolbar-search'),
                $value = $toolbar.find(".filterValue"),
                value = $value.val(),
                condition = $toolbar.find(".filterCondition").val(),
                dataIndx = $toolbar.find(".filterColumn").val(),
                filterObject;

            if (dataIndx == "") {//search through all fields when no field selected.
                filterObject = [];
                var CM = $grid.pqGrid("getColModel");
                for (var i = 0, len = CM.length; i < len; i++) {
                    var dataIndx = CM[ i ].dataIndx;
                    filterObject.push({ dataIndx: dataIndx, condition: condition, value: value });
                }
            }
            else {//search through selected field.
                filterObject = [{ dataIndx: dataIndx, condition: condition, value: value }];
            }

            $grid.pqGrid("filter", {
                oper: 'replace',
                data: filterObject
            });
        }

Which is bind to:

  { type: 'button', label: 'Search', icon: 'ui-icon-search', listeners: [{ click: filterhandler }] },

Let's discuss this part of records:

No | Name | Another column

1   | !1111 | sth else
2.  | !!!222| sth else...
4.  | aaaaa| sth else...
5.  | aabbb| sth else...
6.  | ccsssa| sth else...
7.  | ddddd| sth else...

When I have no sorting mode enabled (or no column for sorting "clicked" - data came like this from dataArray), then type: "aa" to filter and click "Search" (by column "Name", criteria "contain"), my records are like:

4.  | aaaaa| sth else...
5.  | aabbb| sth else...

But then, when I erase search field to "", and click Search, my records are:

4.  | aaaaa| sth else...
5.  | aabbb| sth else...
1   | !1111 | sth else
2.  | !!!222| sth else...
6.  | ccsssa| sth else...
7.  | ddddd| sth else...

instead of:

1   | !1111 | sth else
2.  | !!!222| sth else...
4.  | aaaaa| sth else...
5.  | aabbb| sth else...
6.  | ccsssa| sth else...
7.  | ddddd| sth else...

As You see previously filtered records are show below those, which filter included in view.
So how to reorder records naturally (to the view they were inserted do initial dataArray)?

Inb4: grid declaration is not changed and it's the same from this thread.

14
One more question, after removing all filters previously hidden records are shown after those unfiltered. How to properly sort/order records after reverting filter (setting to "" or empty in value field)? I'm writting in this thread because it's related to source code shown above.

15
Help for ParamQuery Pro / Serious performance problem in Firefox 27.0.1
« on: February 24, 2014, 08:34:47 pm »
Hello again,

I just want to notice that there is a serious performance problem in newest FireFox release (27.0.1). I though that my application fails (I've got many thousands of records in grid) but I've double checked on free version Demo page (infinite scroll) and scroll is reeeeaaallly slow. I've also tried on IE11 and IE11 comparing to FireFox in this version is pure power monster :)

Pages: [1] 2 3