This is a migrated thread and some comments may be shown as answers.
Window Contents Based on Grid Selection
3 Answers 72 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alex
Top achievements
Rank 1
Alex asked on 14 Nov 2010, 08:57 AM
Hello,

I have a view that contains a Telerik Window, and a Grid of "People" objects, which is selectable. I can use 

.LoadContentFrom("AddressLookup", "Person", new { personId = 20 }) // personId is hardcoded.. I want to bind this to Person in grid


in the window definition. How can I pass the PersonId to this action based on the selected row in the People Grid? Do I have to use 

$("#GetAddressWindow").data("tWindow").contentUrl

and regex replace the ID there or is there a cleaner solution?

Thank you.

3 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 15 Nov 2010, 03:56 PM
Hello Alex,

You could serialize the request string and use our formatString function, like this:

    // once on the page
    var urlFormat = '<%= HttpUtility.UrlDecode(Url.Action("AjaxView", "Window", new { id = "{0}" })) %>';

    // when requesting a specific page
    var specificUrl = $.telerik.formatString(urlFormat, 10);
    $('#Window').data('tWindow').ajaxRequest(specificUrl);


Best wishes,
Alex Gyoshev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Donna Stewart
Top achievements
Rank 1
answered on 03 Jan 2011, 05:32 PM
Hi and Happy New Year!  Could you please, please, please post a sample application with this?!  This is exactly what I need, but I'm still fairly new to all of this and I'm not real sure how to use your suggestion.

I have a treeview and I would like to open a window for the user to edit the selected user from the treeview.  Here are excerpts from my code:

<%= Html.Telerik().TreeView().Name("Users").ShowCheckBox(True).HtmlAttributes(New With {.style = "width:250px; height:550px;"}) _
                .BindTo(CType(Model.userList, IEnumerable(Of UserClass)),
                        Sub(mappings)
                            mappings.For(Of UserClass)(
                            Sub(binding)
                                binding _
                                    .ItemDataBound(
                                        Sub(item, usr)
                                            item.Text = usr.userDisplayName
                                            item.Value = usr.userKey
                                            item.LoadOnDemand = True
                                        End Sub)
                            End Sub)
                        End Sub) _
                .DataBinding(Function(dataBinding) dataBinding.Ajax().Select("GetGroupsForUser", "User"))
           
<%  Html.Telerik().Window().Name("EditWindow") _
    .LoadContentFrom("Edit", "User", New With {.id = 10}) _
    .Buttons(Function(buttons) buttons.Refresh().Maximize().Close()) _
    .Draggable(True) _
    .Height(450) _
    .Width(500) _
    .Resizable() _
    .Title("Edit GMC Web User") _
    .HtmlAttributes(New With {.class = "windows7"}) _
    .Visible(False) _
    .Render()
 %>
<%  Html.Telerik().ScriptRegistrar().OnDocumentReady("$('#newUser').bind('click', function openWindow(e){ $('#CreateWindow').data('tWindow').center().open().refresh();})") _
    .OnDocumentReady("$('#editUser').bind('click', function openWindow(e){$('#EditWindow').data('tWindow').center().open().refresh();})")
          
 
%>

Thank you so much!
Donna
0
Hristo Germanov
Telerik team
answered on 04 Jan 2011, 01:15 PM
Hello Alex,

 Thank you for contacting us.

 In order to achieve your goal you need to:
 1. Bind to the telerik tree view and hook up to "OnSelect" client event. In "OnSelect" event you need to get selected item and pass the id to the "TestView" method.

function onSelect(e) {
var urlFormat = '<%= HttpUtility.UrlDecode(Url.Action("TestView", "Home", new { id = "{0}" })) %>';
 
var specificUrl = $.telerik.formatString(urlFormat, $('#AjaxTreeView').data('tTreeView').getItemValue(e.item));
 
var window = $('#Window').data('tWindow');
window.ajaxRequest(specificUrl);
window.center().refresh();
window.open();
}

 2. Add the telerik window and hook up to "OnClose" client event. When you close the window you need to remove selection of the node.
function closeWindow() {
$('#Window').close();
removeSelection();
}
 
function removeSelection() {
$('#AjaxTreeView .t-state-selected').removeClass('t-state-selected');
}

 For your convenience I have attached a sample project reproducing the suggested approach.

Regards,
Hristo Germanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Window
Asked by
Alex
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Donna Stewart
Top achievements
Rank 1
Hristo Germanov
Telerik team
Share this question
or