json - Kendo UI Grid - ClientTemplate calling MVC Url.Action calls (incorrectly) two different actions -
- i have data loads kendo grid via ajax binding.
- within 1 of columns there's clienttemplate calls javascript method (showall).
- this method call action , details of data, putting json response, , open jquery-ui dialog show details.
- when user clicks on link in grid httpget triggered getdetails action but, problem is, triggered entire page's action (index).
the question, guess, causing index action triggered? because, dialog show, detailed data populate, once close dialog filter textboxes reset , grid reload , data within it.
shouldn't action called getdetails?
any hints appreciated!
code:
@(html.kendo().grid<logviewmodel>() .name("loggrid") .columns(column => { column.bound(x => x.stuffcount).title("stuff").width(70) .clienttemplate("<a onclick=\"showall('" + "#= id #')\"" + " href=''>#= stuffcount #</a>"); }) .datasource(databinding => databinding .ajax() .pagesize(50) .read(read => read.action("getdata", "summary") .data("getsearchfilters")) .model(model => model.id(o => o.id))) .events(e => e .databound("ongriditemsdatabound")) .pageable(paging => paging.refresh(true)) )} <div id="dialog-message" title="" style="display: none"> <p id="msg"></p> </div> <script type="text/javascript"> var showall= function (id) { var url = '@url.action("getdetails", "summary")' + "/" + id; var stitle = 'title text'; $.getjson(url, null, function (data) { $("#dialog-message").dialog({ title: stitle }); $("#msg").text(data.details); showmessage(); }); }; var showmessage = function () { $("#dialog-message").dialog({ modal: true, draggable: false, resizable: false, buttons: { ok: function() { $(this).dialog("close"); } } }); }; </script> the controller methods (content removed brevity
public actionresult index(...) { ... } public actionresult getdetails(guid id) { ... (get data repository) return json(data, jsonrequestbehavior.allowget); }
i posted same question on telerik forum. admin pointed me in right direction:
- http://www.kendoui.com/forums/mvc/grid/kendo-ui-grid---clienttemplate-calling-mvc-url-action-calls-(incorrectly)-two-different-actions.aspx
- which "href" value should use javascript links, "#" or "javascript:void(0)"?
turns out had add void href call javascript , stay on page. href="javascript:void(0)"
Comments
Post a Comment