Pass resources to custom popup template

7 posts, 0 answers
  1. Ben
    Ben avatar
    6 posts
    Member since:
    Nov 2014

    Posted 06 Nov 2014 Link to this post

    Just editing your Scheduler example and if I create a custom template for the popup form to create a new event I have no access to the resources like you have in the stock popupform. How do I create that dropdown with the list of users from the resources in my custom template? Thanks.
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 10 Nov 2014 Link to this post

    Hello Ben,

    In general, in the editor form template you will have access to the SchedulerEvent instance. If you would like to retrieve data from the Scheduler's data source, then you will need to get a reference to the object and then bind the widget. Here is a demo that demonstrates this in action. The demos wires the edit event of the widget and then binds the widget to the corresponding resource. Note that you can define the data statically in the custom editor template too, if it is not loaded dynamically.

    Regards,
    Georgi Krustev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Ben
    Ben avatar
    6 posts
    Member since:
    Nov 2014

    Posted 10 Nov 2014 in reply to Georgi Krustev Link to this post

    awesome thanks. Have you got the markup from the demo template where you have a small coloured square next to each name in the dropdown?
  5. Ben
    Ben avatar
    6 posts
    Member since:
    Nov 2014

    Posted 10 Nov 2014 Link to this post

    When I try your code I get Uncaught TypeError: Cannot read property 'dataSource' of undefined 

    my edit:

    edit: function(e) {
              var vehicleId = e.container.find("#vehicleId").data("kendoDropDownList");
              console.log(vehicleId);
              
              //bind the widget to the resources
              vehicleId.dataSource.data(e.sender.resources[0].dataSource.data());
            }
    my template:

     <div data-container-for="vehicleId" class="k-edit-field">
            <select id="vehicleId" data-bind="value:vehicleId" data-role="dropdownlist"
                            data-value-field="value" data-text-field="text">
            </select>
        </div>








  6. Ben
    Ben avatar
    6 posts
    Member since:
    Nov 2014

    Posted 10 Nov 2014 in reply to Ben Link to this post

    Never mind my bad I forgot to uncomment        
     editable: {
                template: $("#editor").html()
            },
    so it was still using default...
  7. bberdel
    bberdel avatar
    20 posts
    Member since:
    Jun 2006

    Posted 03 Jun Link to this post

    I'm trying to do something similar, except my resource entry is using remote access rather than  static values.  When I assign the drop-down's data source in the edit event (as described in this post) I get [ object Object] for each line in the drop-down.   What do I have to do to get the datasource to bind correctly?

    Note: Please do not ask me to provide an application demonstrating the problem - that's just not feasible.

     

  8. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 07 Jun Link to this post

    Hello Brian,

    You can try different approach for loading the editor data - for example you can use custom dataSource "transport.read" operation as demonstrated below:

    1) Inside the editor template:
    <input id="someField" name="someField" data-bind="someField" data-role="dropdownlist"
                          data-value-field="value" data-text-field="text" style="width:100%;"
                          data-source="{transport:{read:getSomeFieldResourceData}}"></input>

    2) On the page where the Scheduler is initialized:
    function getSomeFieldResourceData(e) {
       //make sure the id match your scheduler id
       var scheduler = $("#scheduler").data('kendoScheduler');
       var someFieldResourceIndex = 1; //better solution is to find the index
       var resourcesData = scheduler.resources[someFieldResourceIndex].dataSource.view();
       e.success(resourcesData.toJSON());
    }


    Regards,
    Vladimir Iliev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready