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

Rebind multiple grids

2 Answers 34 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.
neal
Top achievements
Rank 1
neal asked on 10 Apr 2012, 09:46 AM
Hi
I'll start by saying my Javascript isnt amazing :)

I am trying to rebind 2 grids when a row from another is selcted. Here is my code

    function onRowSelected(e) {
        var notes = $('#notes').data('tGrid');
        var clients = $('#clients').data('tGrid');
        id = e.row.cells[0].innerHTML;

        // update ui text
        $('#id').text(id);

        // rebind the related grid
        notes.rebind({ id: id });
        clients.rebind({ id: id });
    }

in this case only the notes grid rebinds

if i swap the last two lines round like so

        clients.rebind({ id: id });
        notes.rebind({ id: id });

only the clients grid rebinds

cananyone help please?

Thanks in advance

2 Answers, 1 is accepted

Sort by
0
neal
Top achievements
Rank 1
answered on 10 Apr 2012, 11:36 AM
I think the problem could be because I am making multiple ajax calls?

i could be wrong tho

heres the script for the whole page

<div class="divCenter">
    <table style="width: 1400px">
        <tr>
            <td>
                <table>
                    <tr>
                        <td style="width: 1100px; padding: 5px">
                            @(Html.Telerik().Grid((IEnumerable<CRM.Lists.lFirms>)ViewData["firms"])
.Name("Firms")
        .Columns(columns =>
            {
                columns.Bound(c => c.id).Width("50px");
                columns.Template(
                @<text>
                            <img
                        alt=""
                        src="../../Images/@item.logo"
                        height="60px" width="50px"
                      />
                            </text>
            ).Title("logo").Width("60px");
                columns.Bound(c => c.name).Title("Firm").HtmlAttributes("style=font:bold");
                columns.Bound(c => c.address1).Title("Address");
                columns.Bound(c => c.postcode).Title("PostCode");
                columns.Bound(c => c.stexpirydate).Title("ST Expiry");
                columns.Bound(c => c.telno).Title("Tel");

                columns.Template(@<text>Web: <a href="Http://@item.websiteurl" target="_blank">@item.websiteurl</a><br />
                            <br />
                            mail: <a href="mailto:@item.email">@item.email</a></text>).Title("Contact").Width("230px").Visible(false);
                columns.Bound(c => c.firmsize).Title("Size");
                columns.Bound(c => c.sector).Title("Sector");
            })

            .Pageable(paging => paging.PageSize(20).Style(GridPagerStyles.NextPreviousAndNumeric).Position(GridPagerPosition.Bottom))
            .Sortable()
            .Filterable()
            .Scrollable(c => c.Height("450px"))
            .Selectable(p => p.Enabled(true))
            .DataKeys(k => k.Add(a => a.id))
            .ClientEvents(events => events.OnRowSelected("onRowSelected"))
            .RowAction(row =>
            {
                row.Selected = row.DataItem.id.Equals(ViewData["id"]);
            })
            )
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 300px">
                            <table>
                                <tr>
                                    <td style="padding: 0">
                                        <div class="header" id="id">
                                        </div>
                                    </td>
                                    <td style="padding: 0">
                                    </td>
                                </tr>
                                <tr>
                                    <td style="padding: 0">
                                        <div class="subHeader">
                                            Notes</div>
                                    </td>
                                    <td style="padding: 0">
                                        <div class="subHeader">
                                            Clients</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 500px; padding: 10px">
                                        @(Html.Telerik().Grid((IEnumerable<CRM.Lists.lNotes>)ViewData["notes"])
.Name("notes")
        .Columns(columns =>
            {
                columns.Bound(c => c.createdby).Title("Created By").Width("60px");
                columns.Bound(c => c.createddate).Title("Date").Width("100px");
                columns.Bound(c => c.notestatus).Title("Status").Width("60px");
                columns.Bound(c => c.notetext).Title("Note");
            })
                  .Sortable()
                  .Filterable()
                  .Scrollable(c => c.Height("150px"))
                  .Selectable(p => p.Enabled(true))
                    .DataBinding(dataBinding => dataBinding.Ajax().Select("_SelectionClientSide_Notes", "Manage", new { id = 14413 }))
                    .Resizable(resizing => resizing.Columns(true))

                .ClientEvents(clientEvents => clientEvents.OnDataBinding("onDataBinding"))

                                )
                                    </td>
                                    <td style="width: 600px; padding: 10px">
                                        @(Html.Telerik().Grid((IEnumerable<CRM.Lists.lClients>)ViewData["clients"])
.Name("clients")
        .Columns(columns =>
            {
                columns.Bound(c => c.title).Title("Title");
                columns.Bound(c => c.firstname).Title("FirstName");
                columns.Bound(c => c.lastname).Title("LastName");
                columns.Bound(c => c.directphone).Title("Tel");
                columns.Bound(c => c.directmobile).Title("Mob");
                columns.Bound(c => c.directfax).Title("fax");
                columns.Bound(c => c.email).Title("Email");
                columns.Bound(c => c.stexpdate).Title("ST Exp");
            })
                  .Sortable()
                  .Filterable()
                  .Scrollable(c => c.Height("150px"))
                  .Selectable(p => p.Enabled(true))
                    .DataBinding(dataBinding => dataBinding.Ajax().Select("_SelectionClientSide_Clients", "Manage", new { id = 14413 }))
                .Resizable(resizing => resizing.Columns(true))
                .ClientEvents(clientEvents => clientEvents.OnDataBinding("OnDataBinding"))

                                )
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 300px">

            </td>
        </tr>
    </table>
</div>
<script type="text/javascript">
    function onRowSelected(e) {

        id = e.row.cells[0].innerHTML;
        str1 = e.row.cells[2].innerHTML;
        // update ui text
        $('#id').text('Firm Selected : '.concat(str1));

        // rebind the related grid        
        var clients = $('#clients').data('tGrid');
        clients.rebind({ clientid: id });

        var notes = $('#notes').data('tGrid');
        notes.rebind({ id: id });

    }
    function onDataBinding(e) {
        e.data = $.extend(e.data, { id: id });
    }

    function OnDataBind(e) {
        e.data = $.extend(e.data, { clientid: id });
    }
</script>

0
neal
Top achievements
Rank 1
answered on 10 Apr 2012, 12:59 PM
the issue was a browser problem

i ran it in IE and it worked, then i ran it in firefox again and it worked in firefox

stumped
Tags
Grid
Asked by
neal
Top achievements
Rank 1
Answers by
neal
Top achievements
Rank 1
Share this question
or