Giving parameters to the datasource (binding)

7 posts, 0 answers
  1. Yngve
    Yngve avatar
    19 posts
    Member since:
    Feb 2017

    Posted 12 Apr Link to this post

    Hi,

     

    I've been searching on the net for some while to see if there's a way to do this. I'll try my best to formulate what I mean in an understandable way.

     

    Example

    Take this view for instance. I was wondering if there's any way to specifiy a parameter to the Action.

     

    What I essentially am trying to do is this; I have a organizational diagram of some business. And say this map only contains the names of the employees and departments. But the view contains different checkboxes for altering the map. If I for instance press a certain checkbox, I would like to see the organizational map with both names AND titles of the employees. So in that case I want to send an int value of for example 1 to the Action to indicate what values the diagram should contain. Is there a way to declare this in the view? 

     

  2. Stamo Gochev
    Admin
    Stamo Gochev avatar
    189 posts

    Posted 13 Apr Link to this post

    Hi Yngve,

    You can provide additional parameters to the DataSource methods as described in this forum thread:

    http://www.telerik.com/forums/pass-additional-parameters-to-read-ajax-datasource-method---mvc


    Regards,
    Stamo Gochev
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Yngve
    Yngve avatar
    19 posts
    Member since:
    Feb 2017

    Posted 18 Apr in reply to Stamo Gochev Link to this post

    Hi, thanks for the answer. How would I go about invoking the read function in a javascript function though?
  4. Tsvetina
    Admin
    Tsvetina avatar
    2107 posts

    Posted 20 Apr Link to this post

    Hi Yngwe,

    You can access the Diagram client instance and call its DataSource read() method like this:
    $("#diagram").data("kendoDiagram").dataSource.read();


    Regards,
    Tsvetina
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. Yngve
    Yngve avatar
    19 posts
    Member since:
    Feb 2017

    Posted 21 Apr in reply to Tsvetina Link to this post

    That didn't seem to work. I got this error: Uncaught TypeError: Cannot read property 'dataSource' of undefined.

    VM511:1 Uncaught TypeError: Cannot read property 'dataSource' of undefined at <anonymous>:1:35
    VM511:1 Uncaught TypeError: Cannot read property 'dataSource' of undefined at <anonymous>:1:35
  6. Tsvetina
    Admin
    Tsvetina avatar
    2107 posts

    Posted 21 Apr Link to this post

    Hello Yngwe,

    Can you confirm that you are calling this line at a point of time when the Diagram is created (already visible) and that your Diagram Name is indeed "diagram"? The id used to find the Diagram jQuery element corresponds to the Name value you set for the Diagram.
    Can you show the code that you are trying to run, maybe update the Pastebin?

    Regards,
    Tsvetina
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  7. Yngve
    Yngve avatar
    19 posts
    Member since:
    Feb 2017

    Posted 21 Apr Link to this post

    Yes, I'm calling it after the Diagram is created and already visible. My diagram name is definitely "diagram". 

    It did however work when I used this code, which I didn't find on your website but after some google searching.

    $("#diagram").getKendoDiagram().dataSource.read();
    $("#diagram").getKendoDiagram().refresh();
Back to Top