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

[Solved] Activate grid.ajax from tree view

0 Answers 75 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Espen Kon
Top achievements
Rank 2
Espen Kon asked on 07 Feb 2011, 12:58 AM
Hei,
I am new in this, however, I am trying to activate the grid ajax with a value I get from the Treeview.
My current approach is:

Set viewdata to receive value by script:
CONTROL
public ActionResult Tree(int id)
{
:
ViewData["SelectedNode"] =
                "<script type='text/javascript'> document.getElementById('nodeSelected').value; </script>";
}

// I will then copy the JS tree value after select.

        [GridAction] // the grid ajax function (work fine)
        public ActionResult _AjaxBinding(int id)
        {
            return View(new GridModel(MyList(id).ToList()));
        }

VIEW
// The value from tree is received well, BUT this is were it does really work further...
    <script type="text/javascript">
        function onSelect(e) {
            var x = document.getElementById("nodeSelected");
            x.value = $('#InstanceTree').data('tTreeView').getItemValue(e.item);
            document.getElementById('nodeSelected').value = x.value;
           /// value from tree should be now copied to element "nodeSelected"
            grid.ajaxRequest();
        }
    </script>

And so, in the grid I should be able to call the ajax with parameters given from the tree.

:
:
<% Html.Telerik().Grid(GList)
                       .Name("Grid")
                       .DataBinding(dbinding => dbinding.Ajax()
                       .Select("_AjaxBinding", "Tree", new { id =  ViewData["SelectedNode"] }))
                       .Pageable(p => p.PageSize(20))
                       .Sortable(s => s.SortMode(GridSortMode.SingleColumn))

It seems there are many holes here - maybe a simple solution could have been in the JS, on grid.ajaxRequest();, just send it with parameters? Any assistance will be appreciated.

Espen
 


Tags
General Discussions
Asked by
Espen Kon
Top achievements
Rank 2
Share this question
or