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

[Solved] Master Detail Grid with RadComboboxes. Can't always get current row with Combobox.SelectedIndexChanged()

3 Answers 210 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 02 Jan 2008, 05:21 AM
Hi

I am using VS2008, .NET 3.5 and C#.

My Prometheus RadGrid is populated with Prometheus RadComboboxes. These in turn fire client-side SelectedIndexChanged events.

I can catch the events nicely. In Javascript I use the following to determine the row the RadComboBox came from (which I can then manipulate other controls in that same row...):

function
cboSubType_SelectedIndexChanged(sender, e)
{
    var item = e.get_item();
    var combo = item.get_comboBox();
    var rowElement = combo.get_parent();

    // Loop through Detail Tables
    
for(var i = 0; i < grid.get_detailTables().length; i++)
    {
        // Loop through Rows
        for(var j = 0; j < grid.get_detailTables()[i].get_dataItems().length; j++)
        {
            if(grid.get_detailTables()[i].get_dataItems()[j] == rowElement)

etc. etc...


The rowElement seems to point to something different when first fired (and hence fails), however 2nd time onwards it always points to a valid row in a detail grid.

The only time it will break again is with a full post-back.

How can I make this work every time?


Kind regards

Mark Eaton

3 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 07 Jan 2008, 07:46 AM
Hi Mark,

I reviewed the logic in the code provided, and it looks correct.
However, in order to properly assist you, I would suggest that you send us a small working project, which demonstrates the way the grid is constructed, as well as any other controls which may be nested in it. Since you cannot attach files to the forum posts, you can open a formal support ticket, and add the code there.
We will review it locally, and advise you further.

All the best,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Mark
Top achievements
Rank 1
answered on 07 Feb 2008, 10:58 PM
Hi

I got a response from my Support Ticket that works every time. I had to use the following altered code:

function cboSubType_SelectedIndexChanged(sender, e)
{
    var rowElement = sender.get_element().parentNode.parentNode

    // Loop through Detail Tables
    
for(var i = 0; i < grid.get_detailTables().length; i++)
    {
        // Loop through Rows
        for(var j = 0; j < grid.get_detailTables()[i].get_dataItems().length; j++)
        {
            if(grid.get_detailTables()[i].get_dataItems()[j].get_id() == rowElement.id)



However I also have a RadDateInput in this grid with an OnValueChanged() event and the above code fails as id always = null.

E.g.:

function dateFrom_OnValueChanged(sender, e)
{
    var rowElement = sender.get_element().parentNode.parentNode;

    // Loop through Detail Tables
    for(var i = 0; i < grid.get_detailTables().length; i++)
    {
            // Loop through Rows
            for(var j = 0; j < grid.get_detailTables()[i].get_dataItems().length; j++)
            {
                if(grid.get_detailTables()[i].get_dataItems()[j].get_id() == rowElement.id)



I did try the original code but that ran into the problem of only working 2nd time onwards.

How can I make this work for RadDateInput as well?



Kind regards

Mark Eaton
0
Accepted
Yavor
Telerik team
answered on 11 Feb 2008, 02:17 PM
Hello Mark,

The approach that you need to use depends on the particular implementation that you have in place - the control structure, and the items nested in it. As I mentioned previously, in order to be able to address the question, it would be best if you send us the current implementation in a formal support ticket. Once I review it locally, I will get back to you with my suggestions.

Regards,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Mark
Top achievements
Rank 1
Share this question
or