This is a migrated thread and some comments may be shown as answers.

[Solved] ajax binding

2 Answers 100 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Doug
Top achievements
Rank 1
Doug asked on 14 Sep 2010, 03:54 PM
I have a screen that displays a record for editing. To keep the user from having to switch mindsets and return to the "list of records", ie. grid, I have a pop-up screen that allows the user to quickly search for the next record to edit. The search screen is a grid. Everything works well except I'd like to delay the binding of the pop-up until the screen is displayed.

I have to reset the grid upon pop-up to clear the previous search so I'm really calling the bind twice, once on the screens initial load and again right before it's made visible. Is there anyway to inhibit the initial call?

I could hack the initial call with a bogus parameter and have the binding return an empty result set but I'd rather not have the back and forth traffic as I'm hosting in a cloud and the network latency is one of the biggest issues.

My only other thought is to trap the call with jquery on the client side and return an empty set, but again another hack that I'd rather not do.

2 Answers, 1 is accepted

Sort by
0
Doug
Top achievements
Rank 1
answered on 14 Sep 2010, 04:16 PM
I found the piece of JS code that allows the behavior that I'm after. In telerik.grid.js starting on line 697 for version Q2 2010 I commented out the call for ajaxbinding. Now I need an option in the aspx page that enables/disables the tr.t-no-data attribute?

    $.fn.tGrid = function (options) {
        return $t.create(this, {
            name: 'tGrid',
            init: function (element, options) {
                return new $t.grid(element, options);
            },
            options: options,
            success: function (grid) {
              //  if (grid.$tbody.find('tr.t-no-data').length)
              //      grid.ajaxRequest();
            }
        });
    }
0
Doug
Top achievements
Rank 1
answered on 14 Sep 2010, 05:09 PM
Ok, I found a workaround that doesn't require changing any Telerik code. It's still a little messy but manageable. The code traps on the existence of a special class tr.t-no-data, so I system wide uniquely name the grid and remove it in a script file that runs earlier, e.g.

$('#emp_search_grid_delay').find('tr.t-no-data').removeClass('t-no-data');

Works perfectly for what I need and reduces the traffic and increases the overall speed of my app.
Tags
Grid
Asked by
Doug
Top achievements
Rank 1
Answers by
Doug
Top achievements
Rank 1
Share this question
or