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

Binding templates from remote data

0 Answers 93 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Ken
Top achievements
Rank 1
Ken asked on 01 Oct 2012, 04:48 PM
Hi,

I've been working on a problem for awhile and am now seeking some help.

This involves a view model with a remote datasource and HTML binding of a template.

I'm using a combination of Bootstrap, Kendo, ColdFusion and SQL Server for my app.  Everything is working well, but I have run into an issue binding a viewModel with an HTML template that is styled using Bootstrap.  I'm pretty certain that the Bootstrap isn't interfering, but it's worth knowing that I am using it.

I am getting an error that "source.parent is not a function" which occurs in line 7405 ("source = source.parent()") of kendo.web.js.

I have a feeling that the problem with the remote datasource, because if I replace it with a local datasource, it works fine.

<div id="workshopsTableContainer">
    <table id="workshopsTable" class="table table-hover table-bordered">
        <thead>
            <tr>
                <th>Site</th>
                <th>Date/Time</th>
                <th>Evaluation Code</th>
                <th></th>
            </tr>
        </thead>
        <tbody data-template="workshopsTableRowTemplate" data-bind="source: workshops"></tbody>
    </table>
</div>
 
<script id="workshopsTableRowTemplate" type="text/x-kendo-tmpl">
<tr>
    <td data-bind="text: site_id"></td>
    <td data-bind="text: workshop_date"></td>
    <td data-bind="text: evaluation_code"></td>
    <td><a class="btn btn-primary">Edit</a></td>
</tr>
</script>
 
$(function(){
    workshopViewModel = kendo.observable({
        workshops: new kendo.data.DataSource({
            transport: {
                read: {
                    url: "/applications/wms/components/API.cfc?method=read",
                    dataType: "json",
                    data: {objType: "workshop", organization_id: 944},
                    type: "POST",
                    cache: false
                },
                parameterMap: function(options, operation) {
                    if (operation !== "read" && options.models) {
                        return {models: kendo.stringify(options.models)};
                    }
                    return options;
                }  
            },
            schema: {
                data: "data",
                total: "recordcount",
                type: "json",
                model: Workshop
            },
            batch: false
        })
    });
     
    kendo.bind($("#workshopsTableContainer"), workshopViewModel);
})
 
var Workshop = kendo.data.Model.define( {
    id: "workshop_id",
    fields: {
        "workshop_id": {
            type: "number",
            editable: true,
            nullable: false
        },
        "site_id": {
            type: "number",
            editable: true,
            nullable: false
        },
        "workshop_date": {
            type: "string",
            editable: true,
            nullable: false
        },
        "evaluation_code": {
            type: "string",
            editable: true,
            nullable: false
        }
    }
});


The workshops source in the vm is not automatically called and isn't available on page load.  If I force a read, I still get the error.  Sorry for all the extra fields in the data, the 4 fields in the model are in there, trust me :)

{"message":"","success":true,"recordcount":5,"data":[{"organization_date_created":"November, 03 2010 20:17:26","organizer_approved":1,"organizer_extension":132.0,"organizer_login_token":"9D31858C-9448-AA47-F48C02E67A5733BF","site_county_id":39,"organization_oap":"<\/string><\/var><\/string><\/var><\/string><\/var>200<\/string><\/var>1,2,3,12,13,17,18<\/string><\/var><\/struct><\/data><\/wddxPacket>","organizer_role":"Organizer","approved":0,"manager_full_name":"Angelique Adams","site_id":865,"site_zip_code":95330.0,"pb_notes":"","site_site_type":"College Campus","manager_deleted":0,"start_date_time":"February, 03 2010 18:00:00","site_organization_id":944,"manager_extension":132.0,"site_deleted":0,"query_date":"October, 01 2012 09:45:26","organizer_region_ids":"","manager_first_name":"Angelique ","organization_id":944,"manager_role":"Organizer","site_address":"16916 S Harlan Rd","site_date_created":"November, 03 2010 20:25:40","manager_date_created":"November, 03 2010 20:17:26","organizer_organization_id":944,"organization_pa":1,"organization_zip_code":95330.0,"manager_organization_id":944,"organizer_last_name":"Adams","organizer_full_name":"Angelique Adams","start_time":"6:00 PM","organizer_phone":"209-858-0077","manager_password":"angel1031","site_site":"ITT Technical Institute","pb_survey_count":0,"organizer_organization3_id":0,"manager_id":95599,"pb_shipped_date":"","organizer_email":"ajadams@itt-tech.edu","organizer_organization2_id":0,"manager_title":"Director of Finance","date_created":"November, 03 2010 20:25:40","organization_organization":"ITT Technical Institute","site_computers":"10 to 20","organization_approved":1,"workshop_date":"2\/3\/2010","organization_city":"Lathrop","organizer_date_created":"November, 03 2010 20:17:26","organizer_organization_id2":"","manager_organization3_id":0,"organizer_first_name":"Angelique ","evaluation_code":"6ztee","organizer_organization_id3":"","organizer_id":95599,"manager_last_name":"Adams","manager_email":"ajadams@itt-tech.edu","organization_logged_in":1,"site_city":"Lathrop","manager_organization_id2":"","manager_phone":"209-858-0077","manager_organization2_id":0,"workshop_id":2120,"manager_organization_id3":"","organizer_title":"Director of Finance","manager_login_token":"9D31858C-9448-AA47-F48C02E67A5733BF","deleted":0,"organization_deleted":0,"manager_region_ids":"","organizer_deleted":0,"pb_survey_count_status":"Uninitiated","manager_approved":1,"organization_county_id":39,"organizer_password":"angel1031","end_date_time":"February, 03 2010 19:00:00","organization_address":"16916 S Harlan Rd","end_time":"7:00 PM"},{"organization_date_created":"November, 03 2010 20:17:26","organizer_approved":1,"organizer_extension":132.0,"organizer_login_token":"9D31858C-9448-AA47-F48C02E67A5733BF","site_county_id":39,"organization_oap":"<\/string><\/var><\/string><\/var><\/string><\/var>200<\/string><\/var>1,2,3,12,13,17,18<\/string><\/var><\/struct><\/data><\/wddxPacket>","organizer_role":"Organizer","approved":1,"manager_full_name":"Angelique Adams","site_id":865,"site_zip_code":95330.0,"pb_notes":"","site_site_type":"College Campus","manager_deleted":0,"start_date_time":"February, 26 2011 11:00:00","site_organization_id":944,"manager_extension":132.0,"site_deleted":0,"query_date":"October, 01 2012 09:45:26","organizer_region_ids":"","manager_first_name":"Angelique ","organization_id":944,"manager_role":"Organizer","site_address":"16916 S Harlan Rd","site_date_created":"November, 03 2010 20:25:40","manager_date_created":"November, 03 2010 20:17:26","organizer_organization_id":944,"organization_pa":1,"organization_zip_code":95330.0,"manager_organization_id":944,"organizer_last_name":"Adams","organizer_full_name":"Angelique Adams","start_time":"11:00 AM","organizer_phone":"209-858-0077","manager_password":"angel1031","site_site":"ITT Technical Institute","pb_survey_count":0,"organizer_organization3_id":0,"manager_id":95599,"pb_shipped_date":"","organizer_email":"ajadams@itt-tech.edu","organizer_organization2_id":0,"manager_title":"Director of Finance","date_created":"January, 18 2011 09:21:32","organization_organization":"ITT Technical Institute","site_computers":"10 to 20","organization_approved":1,"workshop_date":"2\/26\/2011","organization_city":"Lathrop","organizer_date_created":"November, 03 2010 20:17:26","organizer_organization_id2":"","manager_organization3_id":0,"organizer_first_name":"Angelique ","evaluation_code":"icr9w","organizer_organization_id3":"","organizer_id":95599,"manager_last_name":"Adams","manager_email":"ajadams@itt-tech.edu","organization_logged_in":1,"site_city":"Lathrop","manager_organization_id2":"","manager_phone":"209-858-0077","manager_organization2_id":0,"workshop_id":2688,"manager_organization_id3":"","organizer_title":"Director of Finance","manager_login_token":"9D31858C-9448-AA47-F48C02E67A5733BF","deleted":0,"organization_deleted":0,"manager_region_ids":"","organizer_deleted":0,"pb_survey_count_status":"Uninitiated","manager_approved":1,"organization_county_id":39,"organizer_password":"angel1031","end_date_time":"February, 26 2011 13:00:00","organization_address":"16916 S Harlan Rd","end_time":"1:00 PM"},{"organization_date_created":"November, 03 2010 20:17:26","organizer_approved":1,"organizer_extension":132.0,"organizer_login_token":"9D31858C-9448-AA47-F48C02E67A5733BF","site_county_id":39,"organization_oap":"<\/string><\/var><\/string><\/var><\/string><\/var>200<\/string><\/var>1,2,3,12,13,17,18<\/string><\/var><\/struct><\/data><\/wddxPacket>","organizer_role":"Organizer","approved":1,"manager_full_name":"Angelique Adams","site_id":865,"site_zip_code":95330.0,"pb_notes":"","site_site_type":"College Campus","manager_deleted":0,"start_date_time":"February, 03 2011 18:00:00","site_organization_id":944,"manager_extension":132.0,"site_deleted":0,"query_date":"October, 01 2012 09:45:26","organizer_region_ids":"","manager_first_name":"Angelique ","organization_id":944,"manager_role":"Organizer","site_address":"16916 S Harlan Rd","site_date_created":"November, 03 2010 20:25:40","manager_date_created":"November, 03 2010 20:17:26","organizer_organization_id":944,"organization_pa":1,"organization_zip_code":95330.0,"manager_organization_id":944,"organizer_last_name":"Adams","organizer_full_name":"Angelique Adams","start_time":"6:00 PM","organizer_phone":"209-858-0077","manager_password":"angel1031","site_site":"ITT Technical Institute","pb_survey_count":0,"organizer_organization3_id":0,"manager_id":95599,"pb_shipped_date":"","organizer_email":"ajadams@itt-tech.edu","organizer_organization2_id":0,"manager_title":"Director of Finance","date_created":"January, 18 2011 09:22:27","organization_organization":"ITT Technical Institute","site_computers":"10 to 20","organization_approved":1,"workshop_date":"2\/3\/2011","organization_city":"Lathrop","organizer_date_created":"November, 03 2010 20:17:26","organizer_organization_id2":"","manager_organization3_id":0,"organizer_first_name":"Angelique ","evaluation_code":"xz8us","organizer_organization_id3":"","organizer_id":95599,"manager_last_name":"Adams","manager_email":"ajadams@itt-tech.edu","organization_logged_in":1,"site_city":"Lathrop","manager_organization_id2":"","manager_phone":"209-858-0077","manager_organization2_id":0,"workshop_id":2689,"manager_organization_id3":"","organizer_title":"Director of Finance","manager_login_token":"9D31858C-9448-AA47-F48C02E67A5733BF","deleted":0,"organization_deleted":0,"manager_region_ids":"","organizer_deleted":0,"pb_survey_count_status":"Uninitiated","manager_approved":1,"organization_county_id":39,"organizer_password":"angel1031","end_date_time":"February, 03 2011 20:00:00","organization_address":"16916 S Harlan Rd","end_time":"8:00 PM"},{"organization_date_created":"November, 03 2010 20:17:26","organizer_approved":1,"organizer_extension":132.0,"organizer_login_token":"9D31858C-9448-AA47-F48C02E67A5733BF","site_county_id":39,"organization_oap":"<\/string><\/var><\/string><\/var><\/string><\/var>200<\/string><\/var>1,2,3,12,13,17,18<\/string><\/var><\/struct><\/data><\/wddxPacket>","organizer_role":"Organizer","approved":0,"manager_full_name":"Angelique Adams","site_id":865,"site_zip_code":95330.0,"pb_notes":"","site_site_type":"College Campus","manager_deleted":0,"start_date_time":"January, 07 2013 17:00:00","site_organization_id":944,"manager_extension":132.0,"site_deleted":0,"query_date":"October, 01 2012 09:45:26","organizer_region_ids":"","manager_first_name":"Angelique ","organization_id":944,"manager_role":"Organizer","site_address":"16916 S Harlan Rd","site_date_created":"November, 03 2010 20:25:40","manager_date_created":"November, 03 2010 20:17:26","organizer_organization_id":944,"organization_pa":1,"organization_zip_code":95330.0,"manager_organization_id":944,"organizer_last_name":"Adams","organizer_full_name":"Angelique Adams","start_time":"5:00 PM","organizer_phone":"209-858-0077","manager_password":"angel1031","site_site":"ITT Technical Institute","pb_survey_count":0,"organizer_organization3_id":0,"manager_id":95599,"pb_shipped_date":"","organizer_email":"ajadams@itt-tech.edu","organizer_organization2_id":0,"manager_title":"Director of Finance","date_created":"September, 22 2012 12:43:38","organization_organization":"ITT Technical Institute","site_computers":"10 to 20","organization_approved":1,"workshop_date":"1\/7\/2013","organization_city":"Lathrop","organizer_date_created":"November, 03 2010 20:17:26","organizer_organization_id2":"","manager_organization3_id":0,"organizer_first_name":"Angelique ","evaluation_code":"uhc3a","organizer_organization_id3":"","organizer_id":95599,"manager_last_name":"Adams","manager_email":"ajadams@itt-tech.edu","organization_logged_in":1,"site_city":"Lathrop","manager_organization_id2":"","manager_phone":"209-858-0077","manager_organization2_id":0,"workshop_id":3520,"manager_organization_id3":"","organizer_title":"Director of Finance","manager_login_token":"9D31858C-9448-AA47-F48C02E67A5733BF","deleted":0,"organization_deleted":0,"manager_region_ids":"","organizer_deleted":0,"pb_survey_count_status":"Uninitiated","manager_approved":1,"organization_county_id":39,"organizer_password":"angel1031","end_date_time":"January, 07 2013 19:00:00","organization_address":"16916 S Harlan Rd","end_time":"7:00 PM"},{"organization_date_created":"November, 03 2010 20:17:26","organizer_approved":1,"organizer_extension":132.0,"organizer_login_token":"9D31858C-9448-AA47-F48C02E67A5733BF","site_county_id":39,"organization_oap":"<\/string><\/var><\/string><\/var><\/string><\/var>200<\/string><\/var>1,2,3,12,13,17,18<\/string><\/var><\/struct><\/data><\/wddxPacket>","organizer_role":"Organizer","approved":0,"manager_full_name":"Angelique Adams","site_id":865,"site_zip_code":95330.0,"pb_notes":"","site_site_type":"College Campus","manager_deleted":0,"start_date_time":"February, 07 2013 17:00:00","site_organization_id":944,"manager_extension":132.0,"site_deleted":0,"query_date":"October, 01 2012 09:45:26","organizer_region_ids":"","manager_first_name":"Angelique ","organization_id":944,"manager_role":"Organizer","site_address":"16916 S Harlan Rd","site_date_created":"November, 03 2010 20:25:40","manager_date_created":"November, 03 2010 20:17:26","organizer_organization_id":944,"organization_pa":1,"organization_zip_code":95330.0,"manager_organization_id":944,"organizer_last_name":"Adams","organizer_full_name":"Angelique Adams","start_time":"5:00 PM","organizer_phone":"209-858-0077","manager_password":"angel1031","site_site":"ITT Technical Institute","pb_survey_count":0,"organizer_organization3_id":0,"manager_id":95599,"pb_shipped_date":"","organizer_email":"ajadams@itt-tech.edu","organizer_organization2_id":0,"manager_title":"Director of Finance","date_created":"September, 22 2012 12:44:08","organization_organization":"ITT Technical Institute","site_computers":"10 to 20","organization_approved":1,"workshop_date":"2\/7\/2013","organization_city":"Lathrop","organizer_date_created":"November, 03 2010 20:17:26","organizer_organization_id2":"","manager_organization3_id":0,"organizer_first_name":"Angelique ","evaluation_code":"ib96k","organizer_organization_id3":"","organizer_id":95599,"manager_last_name":"Adams","manager_email":"ajadams@itt-tech.edu","organization_logged_in":1,"site_city":"Lathrop","manager_organization_id2":"","manager_phone":"209-858-0077","manager_organization2_id":0,"workshop_id":3521,"manager_organization_id3":"","organizer_title":"Director of Finance","manager_login_token":"9D31858C-9448-AA47-F48C02E67A5733BF","deleted":0,"organization_deleted":0,"manager_region_ids":"","organizer_deleted":0,"pb_survey_count_status":"Uninitiated","manager_approved":1,"organization_county_id":39,"organizer_password":"angel1031","end_date_time":"February, 07 2013 20:00:00","organization_address":"16916 S Harlan Rd","end_time":"8:00 PM"}]}

No answers yet. Maybe you can help?

Tags
MVVM
Asked by
Ken
Top achievements
Rank 1
Share this question
or