Hi, I have a problem with my grid. This grid is showed to the user, in a popup, when he click on a link.
This is my grid:
<div id="dialog" > <telerik:RadGrid ID="RadGrid1" RenderMode="Lightweight" ClientDataSourceID="RadClientDataSource1" AllowPaging="false" AllowSorting="false" AllowFilteringByColumn="false" PageSize="5" runat="server" > <MasterTableView DataKeyNames="Name" ClientDataKeyNames="Name" > <Columns> <telerik:GridBoundColumn DataField="Name" HeaderText="Name"> </telerik:GridBoundColumn> </Columns> </MasterTableView> </ClientSettings>--%> </telerik:RadGrid></div>
and this is my RadClientDataSource:
<telerik:RadClientDataSource ID="RadClientDataSource1" runat="server" > <ClientEvents OnCustomParameter="ParameterMap" OnDataParse="Parse" /> <DataSource> <WebServiceDataSourceSettings BaseUrl="../ReportService.svc/"> <Select Url="GetFlusso" DataType="JSON" RequestType="Post" ContentType="application/json; charset=utf-8" EnableCaching="false" /> </WebServiceDataSourceSettings> </DataSource> <Schema ResponseType="JSON" > <Model> <telerik:ClientDataSourceModelField FieldName="Name" DataType="String" /> </Model> </Schema></telerik:RadClientDataSource>
This is my link (created with javascript):
"<a href='javascript: openScartiDialog(" + id + ");'><em>CLICK</em></a>"where id is a parameter for a select method on web service.
Now, these are the functions that parse to/from my web service:
function ParameterMap(sender, args) { if (args.get_type() == "read" && args.get_data()) { var dialog = $("#dialog"); var id = dialog.id; if (id != undefined) { var request = { InputContract: { IdFlusso: id } }; args.set_parameterFormat(kendo.stringify(request)); } } else {}}function Parse(sender, args) { var response = args.get_response().Output; if (response) { if (response.length > 0) { args.set_parsedData(response); } else { var model = []; } }}
All works. My Web Service works (I have tried with other grids).
The problem is: the request on the server (performed by the RadClientDataSource, called by the RadGrid) is made on page load.
I want to avoid this, I just want that the grid is loaded, showed on the link click (indeed, I want to pass the id parameter). But I don't know how.
To be more clear, this is the rest of my implementation: the js code for showing/hiding the popup and for set the id.
$(function () { $("#dialog").dialog({ autoOpen: false, modal: true, show: "blind", hide: "blind", width: "auto", buttons: { "OK": function () { $(this).dialog("close"); }, "Annulla": function () { $(this).dialog("close"); } } });});function openScartiDialog(id) { var div = $("#dialog"); div.attr('id', id); div.dialog("open"); var grid = $telerik.findGrid("RadGrid1"); var m = grid.get_masterTableView(); m.rebind(); return false;}
