DataGrid:onLoadSuccess() question

(1/2) > >>

mzeddd:
Hi,

I have small problem.

I use onLoadSuccess() in order to understand when Data is loaded so I could update menus to fit current data.
Everything is fine, but I get problem in case of this:

1) I load data into DataGrid (using URL)
2) select any record
3) call any action to update data on DB side
4) reload DataGrid content using "reload" method
5) selected record stays selected (what is really-very good)
6) call "menuUpdater" function using onLoadSuccess() event.

But as soon as I need to update my menus in accordance with what is selected now I check what is selected now via "getSelections"
I check parameters of my selected record but the value I'm interesting in is old. (the same as I had in step #2)

How can I understand when DataGrid is completely loaded and ready?

Any event like "onAfterLoad"?

Currently I see only one way - use setTimeout() function, but I don't like this solutions so much.

Thanks

//Valery






stworthy:
Please try to override the $.fn.datagrid.defaults.loader to use the 'onLoadSuccess' event.
Code:

<script>
$.fn.datagrid.defaults.loader = function(param, success, error){
var target = this;
var opts = $(target).datagrid('options');
if (!opts.url) return false;
$.ajax({
type: opts.method,
url: opts.url,
data: param,
dataType: 'json',
success: function(data){
var onLoadSuccess = opts.onLoadSuccess;
opts.onLoadSuccess = function(){};
success(data);
opts.onLoadSuccess = onLoadSuccess;
opts.onLoadSuccess.call(target, data);
},
error: function(){
error.apply(this, arguments);
}
});
};

mzeddd:
Hi,

Thanks stworthy.

This is what I've been looking for.

//Valery

mzeddd:
Hi stworthy,

Can this code be turned into new event?
Overriding of existing functions can work without any problems only some not very long time.
It is not safe in long term perspective because we could not predict how our code will work with new EasyUI version(s)

//V

stworthy:
The 'onLoadSuccess' event will be improved in next version to support this feature. You can download the patch file from http://www.jeasyui.com/download/downloads/jquery-easyui-1.3.6-patch.zip. The features in this patch will be integrated into next version.

Navigation

[0] Message Index

[#] Next page