简体   繁体   English

使用extjs4更改网格

[英]changing grid using extjs4

I am working on an extjs 4.2 app in with php mysql backend. 我正在使用php mysql后端处理extjs 4.2应用程序。 I have a json response with student name, Exam, subject, Marks in one row. 我有一个json回复与学生姓名,考试,科目,标记在一行。 Same are sent by mysql Database. 同样是由mysql数据库发送的。 I am trying to reconfigure grid as shown below: 我正在尝试重新配置网格,如下所示:

在此输入图像描述

So essentially marks of Sem-1 and English are part of one record. 因此,基本上Sem-1和英语的标记是一个记录的一部分。 However, marks of Sem-2 and English are part of second record. 但是,Sem-2和英语的标记是第二记录的一部分。 So far I can show subjects and semesters. 到目前为止,我可以展示科目和学期。 Semesters can be shown in grid column reconfigure as well. 学期也可以在网格列重新配置中显示。 But my understanding is one complete record can be shown in a row. 但我的理解是一条完整的记录可以连续显示。 Maybe done through grid tpl. 也许通过grid tpl完成。 Can you please help me. 你能帮我么。 If changes in json are required, we can do that as well 如果需要更改json,我们也可以这样做

currently My json is {"data":[{"MarkID":20,"studentID":2,"ExamName":"Semester-1","Subject":"Science",‌​"MaxMarks":100,"MarksRecvd":15},{"MarkID":21,"studentID":2,"ExamName":"Semester-2‌​","Subject":"Social Science","MaxMarks":100,"MarksRecvd":25}]} 目前我的json是{“data”:[{“MarkID”:20,“studentID”:2,“ExamName”:“Semester-1”,“Subject”:“Science”,“MaxMarks”:100,“ MarksRecvd“:15},{”MarkID“:21,”studentID“:2,”ExamName“:”Semester-2“,”Subject“:”Social Science“,”MaxMarks“:100,”MarksRecvd“:25 }]}

So every subject-Semester combination is a record and I can easily display every record in grid. 因此,每个科目 - 学期组合都是一个记录,我可以轻松地显示网格中的每个记录。

However I am looking to combine marks of various semesters in one subject...so in a way @TheShalit is right that json can b changed and all marks are displayed in one row 但是我希望在一个主题中结合各个学期的标记...所以在某种程度上@TheShalit是正确的,json可以改变,所有标记都显示在一行

You can use dataview for displaying data using custom layout templates and formatting. 您可以使用dataview使用自定义布局模板和格式显示数据。

The View uses an Ext.XTemplate as its internal templating mechanism, and is bound to an Ext.data.Store so that as the data in the store changes the view is automatically updated to reflect the changes. View使用Ext.XTemplate作为其内部模板机制,并绑定到Ext.data.Store,以便随着商店中的数据更改,视图会自动更新以反映更改。

Your tpl could be something like this : 你的tpl可能是这样的:

var tableTpl = new Ext.XTemplate(
        '<tpl>'+
        '<table class="tableViewDemo" width="100%" height="100%" padding="" border="1">' + 
        '<tr>' + 
        '<td width="50%" height="5%" style="padding-left:2%;">Subject</td>' + 
        '<td width="50%" height="5%" style="padding-left:2%;">Semester-1 Marks</td>' + 
        '</tr>' + 
        '</tpl>' +
        '<tpl for=".">'+
        '<table class="tableViewDemo" width="100%" height="100%" padding="" border="1">' + 
        '<tr>' + 
        '<td width="50%" height="5%" style="padding-left:2%;">{subject}</td>' + 
        '<td width="50%" height="5%" style="padding-left:2%;">{sem1}</td>' + 
        '</tr>' + 
        '</tpl>'            
    );

Here is the simple demo in context to your requirement : DataView ExJs4.2 Demo 以下是根据您的要求进行的简单演示: DataView ExJs4.2 Demo

You can modify tpl accordingly.For more details : Ext.XTemplate 您可以相应地修改tpl。有关更多详细信息: Ext.XTemplate

Can you show what you are trying to achieve? 你能展示你想要实现的目标吗?

I think the best way is to change the json record and add data as [subject,s1,s2,s3,s4] 我认为最好的方法是更改json记录并将数据添加为[subject,s1,s2,s3,s4]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM