首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >电传甘特图

电传甘特图
EN

Stack Overflow用户
提问于 2015-02-06 12:00:47
回答 1查看 1.3K关注 0票数 0

我有两个问题

  1. 动态生成的JSON对象(jsonString)在kendo.data.GanttDataSource中为空。我如何在这里调用dataSource.read()?

代码语言:javascript
复制
var jsonObj = []; var jsonString = null;
$(document).ready(function () {
	var url = test.siteUrl() + "/_vti_bin/omg/tt.svc/Read/" + _campaign.CampaignWebID + "/" + _campaign.CampaignListID + "/" + _campaign.ID + "?t=" + of360.t();
	
	$.getJSON(url, function (data) {    
		$.each(data, function (i) {
		
		item = {}
		item['ID'] = data[i].ID;
		item['ChannelDescription'] = data[i].ChannelDescription;
		item['Start'] = data[i].Start;
		item['End'] = data[i].End;	
		item['PercentageComplete'] = data[i].BriefingState/10;
		item['Name'] = data[i].Name;
		jsonObj.push(item);
		});
		jsonString = JSON.stringify(jsonObj);
        //regex : Json remove quotes
		jsonString = jsonString.replace(/"(\w+)"\s*:/g, '$1:');
		//alert(jsonString);
		
	});
});

var ganttModel = kendo.observable({  
	cancel: function () {
		this.cancelDialog();
	}, 
	isVisible: true,               
	ganttDS: new kendo.data.GanttDataSource({
		data: jsonString,
		schema: {
			model: {   
					id: "id",			
				fields: {
					Id: { from: "ID", type: "number" },
					start: { from: "BriefingStart", type: "date"},                                
					end: { from: "BriefingEnd", type: "date" },
					title: { from: "BriefingChannelDescription", type: "string" }, 
					PercentageComplete: {from:"PercentageComplete", type: "number"}
				}
			}
		}		
	})
});

  1. 如何在模板中激活工具栏导出为PDF?我的尝试没有工作数据-工具栏=“pdf” data-pdfExport="true“

代码语言:javascript
复制
<script id="ganttChartTemplate" type="text/x-kendo-template">
<div id="ganttchart"> 
<div class="modal-body">
            <div class="row">
                <div class="form-group">
					<div data-role="gantt"
								data-columns="[				
									 { field: 'title', title: 'Gattung', width: 100 },								
									 { field: 'start', title: 'Start Time', format: '{0:dd/MM/yyyy}', width: 100 },
									 { field: 'end', title: 'End Time', format: '{0:dd/MM/yyyy}', width: 100 }									 
								 ]"
								data-views="[ 'day', { type: 'week', selected: true }, 'month' , 'year']"
								data-show-work-hours="true"
								data-show-work-days="true"
								data-height="300"
								data-editable="false"
								data-listWidth="600"
								data-toolbar="[""pdf""]"	
								data-pdfExport="true"								
								data-bind="source: ganttDS"></div>
				</div>
	        </div>
			<div class="k-dialog-buttons modal-footer">      

        <button class="k-button k-primary" data-bind="events: { click: cancel }">#= Resources.OF360.SendToBuyingDialogCancel#</button>
		
    </div>
		</div>	
</div>
</script>

我很感谢你的帮助。

EN

回答 1

Stack Overflow用户

发布于 2015-02-10 12:05:28

  1. 不幸的是,jsonObj没有工作,我甚至尝试使用ganttDS.read()再次断言它。什么都没用。我用解析解决了这个问题

代码语言:javascript
复制
 parse: function (response) {			
            $.each(response, function (idx, elem) {                    
                var state = elem.BriefingState;
                   elem.BriefingState = state/11;
            });
            return response;
        }	

  1. 数据-工具栏=“‘pdf’”仍然没有工作,我也尝试了它作为一个字符串数组与花括号。我通过在模型中调用函数本身来解决这个问题。

代码语言:javascript
复制
savePdf : function(){
		var gantt = $("#gantt").data("kendoGantt");
		gantt.saveAsPDF();
	},

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28365357

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档