EasyUI Forum
May 03, 2024, 04:29:38 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
  Home Help Search Login Register  
  Show Posts
Pages: 1 2 3 [4]
46  General Category / EasyUI for jQuery / Re: datebox and datetimebox with edatagrid, formatting and parsing on: October 27, 2014, 11:06:13 AM
Hi, OK we are now back to where I started  Wink

So my problem is that when I override formatter and parser to implement localised format, this stops working when used as an edatagrid editor.

The reason seems to be the dataflow:

1) The data value in ISO format goes through 'formatter' and is changed to localised format
2) The editor is opened, the value goes through 'parser' which fails because it expects ISO format, but received localised format
3) Now using a parser that works with either format, I can get further, but now 'saveRow' of edatagrid is picking up localised format, and sending this to the controller.
4) Controller fails as it expected ISO format.

What I seem to need, is a 'datebox' and 'datetimebox' control, that keeps data in ISO format at all times, but displays in localised format.
I know that combo's generally have a textfield (added on init) and a valuefield (the original input element) - could I intercept the value going back and forward between these somehow?

I have gotten so far by overrides - the last piece of the puzzle seems to be ensuring that ISO format is re-established before 'saveRow'.
The next problem is now performance: As my formatter and parser become more complicated having to determine which format is currently being processed, the overall performance of datagrid goes downward. This isn't helped by the fact that these functions seems to be called 2-3 times per event.
47  General Category / EasyUI for jQuery / Re: datebox and datetimebox with edatagrid, formatting and parsing on: October 27, 2014, 06:18:41 AM
Thanks again stworthy!

I can see that works nicely, but I think that is because the data format and display format are now the same (ISO) format, so easyui datebox is now happy.

I was trying to maintain this format for data storage and interchange with the controller, but for the View to be able to apply a localised format. Is this possible with a datebox?

Edit: is it also possible to allow NULL date value handling with easyui, as trying to allow null values results in them being replaced with today's date in most cases. When I try to override to allow nulls, the easyui code fails because date functions can't be called on the null values Sad
48  General Category / EasyUI for jQuery / datebox and datetimebox with edatagrid, formatting and parsing on: October 24, 2014, 10:36:42 AM
Hi, hope someone can help, I have a head-shaped depression in the wall by my desk!

Please see this fiddle: http://jsfiddle.net/phunksta/4uf1cnvv/1/

My data is returned in ISO format, I use column formatter to call the custom formatter of the datetimebox to display the values before editing.
On edit, the date is parsed OK
On opening the datebox calendar, the current date is selected - I'm ok with this, but strangely the parser was called during this process!
Now, on selecting a date, the datetimebox parser is called again, but on a formatted versions of the value, not the original or newly selected!

Can anyone help me get this round-trip working?

Thanks!
49  General Category / EasyUI for jQuery / Re: Combogrid + scrollview, ID is not translated to Value on: October 21, 2014, 05:50:27 AM
Hi Again,

I've picked up a fresh download of the file. I can see it is new because you have fixed another issue I posted about! Brilliant thanks!

But, unfortunately, I still get infinite triggers of the onFetch event Sad

EDIT: I was just trying the chrome monitorEvent() facility, and it is a 'scroll' event that is constantly being triggered. Strange.  Huh
50  General Category / EasyUI for jQuery / Re: Combogrid + scrollview, ID is not translated to Value on: October 15, 2014, 02:50:54 AM
Hi stworthy,

I tried this suggestion today, and found something strange?
I just popped this into my combogrid:

Code:
        onFetch: function (page,rows) {
            console.log('onFetch');
        }

What I got was an infinite number of logs.

I also tried onLoadSuccess, and got the same.

Very strange, is there something going wrong here, or by logging the event in this way have I broken it somehow?
51  General Category / EasyUI for jQuery / Re: datagrid virtual scroll view refresh current page on: October 13, 2014, 10:04:14 AM
Brilliant thank you, I will give this a try!

EDIT: This worked wonderfully thank you!
52  General Category / EasyUI for jQuery / datagrid virtual scroll view refresh current page on: October 13, 2014, 04:20:54 AM
Hi,

I'm hoping this is a simple question with a simple answer!

I have a datagrid with virtualscrollview, and would like to be able to refresh just the current page of data.
So if the user has scrolled to page 2, then after a while the user clicks a button (or some other javascript event), then the datagrid's current page reloads without going back to page 1, which is what seems to happen when I call dg.datagrid('reload')

I can see a reload() function inside scrolling() inside onBeforeRender() in the scrollview code, but I have no idea how to call it?!

Any help very much appreciated!
53  General Category / General Discussion / ODATA enabled datagrid on: September 22, 2014, 08:30:14 AM
Hi all,

In a recent project that will hopefully use EasyUI, I have been trying to integrate datagrid with an c#.net WEB API 2 ODATA endpoint.
ODATA has some very nice features including a built-in set of operations for pagination and filtering, which do not require manual coding in the controller.

http://www.odata.org/documentation/odata-version-2-0/uri-conventions/

So in short ODATA expects URI parameters such as: $top, $orderby, $skip, $filter amongst others.

Back to EasyUI, and a datagrid with scrollview, filter row all in remote mode has a set of parameters that are passed: sort, order, page, rows and q,filterRules

My mission was to try to integrate the 2 so they would talk the same language. It would be fantastic if the EasyUI objects had a mode or switch to name the parameters; if anyone knows how to do this I would be very interested to hear as everything that follows might be superfluous!

Anyway, I present a couple of wrapper functions I have used to make this happen, for discussion, improvement, picking holes etc.
If you make use of these please let me know as I'd like to stay in touch regarding improving them!

Globals:
Here I am currently holding a map for translating filters, and a map for escaping literals
Code:
//maps
var fmap = {
    "contains": "substringof({v},{f}) eq true",
    "equal": "{f} eq {v}",
    "notequal": "{f} ne {v}",
    "beginwith": "startswith({f},{v}) eq true",
    "endwith": "endswith({f},{v}) eq true",
    "less": "{f} lt {v}",
    "lessorequal": "{f} le {v}",
    "greater": "{f} gt {v}",
    "greaterorequal": "{f} ge {v}"
};
var dtmap = {
    "String": "'{v}'",
    "DateTime": "DateTime'{v}'",
    "Default": "{v}"
};

On to datagrid:
Note that I had to ensure that the 'columns' property included a property for the datatype of the column, as I could not find another way to ensure that the literal values were included properly. I'd love to improve this.
Filterstringify property for datagrid:
Code:
        filterStringify: function (data) {
            var $cols = $(this).attr('columns')[0];

            $(data).each(function (ind, entry) {
                var result = $.grep($cols, function (e) { return e.field == entry.field; });
                entry._edmType = result[0]._edmType;
            });
            return odatafilterstringify(data);
        }

Filter stringify function:
Code:
function odatafilterstringify(filt) {
    var rv = "";

    $(filt).each(function (ind, entry) {
        if (ind != 0) rv += ' and ';
        var cst = dtmap[entry._edmType] || dtmap["Default"];
        if (entry._edmType == "DateTime") {
            var v = jsonDate(entry.value);
        }
        else
            var v = entry.value;
        rv += fmap[entry.op].replace(/{f}/g, entry.field).replace(/{v}/g, cst.replace(/{v}/g, v));
    });
    return rv;
}

Custom loader for the datagrid - I haven't found a way to pick up the url property from the datagrid's properties instead of hardcoding it here:
Code:
        loader: function (param, success, error) {
            lkpGetfieldsModel(id, param);
            var odataparam = odataparamwrapper(param, 'Name');
            showDebug(odataparam);
            jQuery.ajax({
                dataType: 'json',
                url: '/odata/entityname',
                data: odataparam,
                success: function (data) {
                    success(odataresponsewrapper(data));
                },
                error: function () {
                    error.apply(this, arguments);
                }
            });
        }

Parameter wrapper:
Code:
        loader: function (param, success, error) {
            lkpGetfieldsModel(id, param);
            var odataparam = odataparamwrapper(param, 'Name');
            showDebug(odataparam);
            jQuery.ajax({
                dataType: 'json',
                url: '/odata/Model',
                data: odataparam,
                success: function (data) {
                    success(odataresponsewrapper(data));
                },
                error: function () {
                    error.apply(this, arguments);
                }
            });
        }

Response wrapper:
Code:
function odataresponsewrapper(data) {
    var newdata = { rows: data.value, total: data["odata.count"] };
    return newdata;
}


 
54  General Category / EasyUI for jQuery / Combogrid + scrollview, ID is not translated to Value on: September 22, 2014, 08:12:40 AM
Hello all,

I have a problem with a Combogrid.
The data for this combogrid is obtained remotely, and the grid object is also using 'view:scrollview' because initially the data can be very large; possibly many 1000's of rows.

When my form loads, the Combogrid is bound to my ID field, in this case 'ModelID'.
This might load with a value such as 123.

The Combogrid is set up with:

Code:
$('#myform input.ModelID').combogrid({
        idField: 'ID', textField: 'Name',
        mode: 'remote',
        loadMsg: 'Querying Database...',
        panelWidth: '380',
        multiSort: true,
        singleSelect: true,
        pageSize: 50,
        view: scrollview,
        remoteSort: true,
        remoteFilter: true

... so when the form loads and the combogrid is initialised, the ID=123 should translate to Name='BlueModel' and the Value should then display in the textbox of the combogrid.

If the ID entry is in the first page of the combogrid data, all is well, the value is displayed.
The problem is that if the ID entry is NOT on the first page (i.e. the entry will not be in the combogrid's data property until the user scrolls down) then the Value is not displayed, the ID is shown instead. If the user does scroll down until the page of the entry, it is then translated.

When my form loads, I actually have another field 'Model' which already contains the translated value 'BlueModel', but I can't find a property or method for combogrid that will allow me to set the initial text value rather than attempt a lookup against the data property.

Can anyone help with either a way to ensure that the current ID value is looked up, or some way to initialise the combogrid textbox? Is trying to combine combogrid and scrollview a bad idea? (I also have datagrid-filter on this datagrid too, but that's another story!)

Many Thanks.

PS I really like EasyUI, it seems to do everything - that is until I make things too complicated!


Pages: 1 2 3 [4]
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!