Paul-DS / bootstrap-year-calendar

[DEPRECATED] A fully customizable year calendar widget, for boostrap !
Apache License 2.0
294 stars 243 forks source link

Trouble Rendering Datasource from SQL query #263

Closed UlquiorraC closed 4 years ago

UlquiorraC commented 4 years ago

I am having trouble rendering a SQL query as my dataSource

dataSource: function(e, j) {

                        $.ajax({
                          url: 'myURL',
                          dataType: "json",
                          success: function(response) {
                            var filter_data = {
                                    names: [],
                                    descs: [],
                                    start_dates: [],
                                    end_dates: []
                                }; 

                                $.each(response.data, function(i, e) {

                                    filter_data.names.push(e.d[0]); 
                                    filter_data.descs.push(e.d[1]);
                                    filter_data.start_dates.push(e.d[2]);
                                    filter_data.end_dates.push(e.d[3]);

                            });

                             var data_source = []; 

                             for (var i = 0; ee.isLT(i, filter_data.names.length); i++) {
                                    data_source.push({
                                        name: filter_data.names[i],
                                        description: filter_data.descs[i],
                                        startDate: new Date(filter_data.start_dates[i]),
                                        endDate: new Date(filter_data.end_dates[i]),
                                  });
                            }
                            $(e.target).data('calendar').setDataSource(data_source);
                          }
                        });

                    }

Let me know what is being done incorrect.

The filter data has to be manipulated for it to be correct before I push the attributes in the data_source object