weixin_33695082 2013-09-17 10:45 采纳率: 0%
浏览 13

单击部分视图

I have Controller:

public ActionResult Index(string Activites)
{
    var item2 = (from o in frh.Dates orderby o.Date1 select o.Date1).ToArray();

    int lenght = item2.Count();

    string[] data = new string[lenght];
    DateTime[] data3 = new DateTime[lenght];
    object[] data2 = new object[lenght];
    double?[] last = new double?[lenght];

    // liste des mois -- string 
    for (int i = 0; i < lenght; i++)
    {
        data[i] = item2[i].ToString("dd/MM/yyyy");

        //if (data[i].Equals(Dates))
        //{ break; }
        //if (data[i] == Dates) break;
    }

    //list des mois -- datetime
    for ( var l = 0; l < lenght; l++)
    {
        data3[l] = item2[l];
        //  if (data3[l].Equals(Dates)) break;
        // if (data3[k].ToString("dd/MM/yyyy") == Dates) break;
    }

    //calcul de productivité 
    // changement ???
    var items = (from x in frh.productivites
                 where x.Activité == Activites
                 select new { x.delta_, x.tempstot_, x.DateID });


    var j = 0;

    foreach (var a in data3)
    {
        var sumd = items.Where(c => c.DateID == a).Select(c => c.delta_).Sum();
        var sumt = items.Where(c => c.DateID == a).Select(c => c.tempstot_).Sum();
        var prod = sumd / sumt;
        last[j] = prod;
        j++;
        sumd = 0;
        sumt = 0;
        prod = 0;
    }

    data2 = last.Cast<object>().ToArray();

    DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart")
    .SetXAxis(new XAxis
    {
        Categories = data
    })
    .SetYAxis(new YAxis
    {
        Title = new YAxisTitle { Text = "Productivité " },
        PlotLines = new[]
        {
            new YAxisPlotLines
            {
                Value = 0,
                Width = 1,
                Color = ColorTranslator.FromHtml("#808080")
            }
        }
    })
    .SetTitle(new Title
    {
        Text = Activites,
        X = -20
    })
    .SetSubtitle(new Subtitle
    {
        Text = "Décembre 2012 - Juin 2013",
        X = -20
    })
    .SetSeries(new Series
    {
        Name = "ODR", 
        Data = new Data(data2)
    });

    return PartialView(chart);
}

and Partial View :

@model DotNet.Highcharts.Highcharts
@(Model)   

@section Scripts {
    @Scripts.Render("~/bundles/HighChart")
}

and view :

@{
    ViewBag.Title = "Index";
}

<html>
    <body>
        @using (Html.BeginForm("Index", "Graphe"))
        {
        <table style="width: 100%;" border="1">
            <tbody>
                <tr aria-atomic="False" class="alt">
                    <td>date début :</td>
                    <td><input value="01/12/2012" type="text"  disabled/></td>
                    <td style="width: 20%; position:absolute ">&nbsp;&nbsp;&nbsp;&nbsp</td>
                </tr>
                <tr>
                    <td>date fin :</td>
                    <td><select id="Dates" name="Dates"  ><option>Selectionnez --</option></select></td>
                    <td><input id="date" type="checkbox" /> </td>
                </tr>
                <tr class="alt">
                    <td>Activité : </td>
                    <td><select id="Activites" name="Activites"  ><option>Selectionnez --</option></select></td>
                    <td><input id="activite" type="checkbox" /> </td>    
                </tr>
                <tr>
                    <td>Responsable:</td>
                    <td><select id="Responsables" name="Responsables">
                        <option>Selectionnez --</option></select></td>
                    <td><input id="Responsable" type="checkbox" /> </td>
                </tr>
                <tr style="height : 30%">
                    <td style="width: 20%">&nbsp;&nbsp;&nbsp;&nbsp</td>
                </tr>
                <tr>
                    <td style="width: 20%; position:absolute "></td>
                    <td><input type="submit" value="Afficher" id="ButtonSubmit"/></td>
                    <td><input class="button" id="ButtonReset" type="button" value="Annuler"  /></td>
                </tr>
            </tbody>
        </table>  
        }
    </body>
</html>

What I want is to show partial View on button click ; I need also to pass parameters (selected values) from view to controller for filtering the collection rendered in the partial view, How could I do that ?

  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 GEO下载数据的处理报错 :函数‘Meta’标签‘"data.frame"’找不到继承方法,如何解决?
      • ¥15 DLNM模型是否可以用二分类变量作为y变量
      • ¥15 android object box 一个实体多个表怎么写
      • ¥15 temux 启用docker 服务失败
      • ¥15 Flask 使用celery发送邮件出现‘目标计算机积极拒绝‘
      • ¥60 老人用的sd卡在手机里面不知道操作了什么,导致图片和视频变成了文件,取下sd卡连接电脑就是图中的样子,后缀改为.jpg才可以,需要用系统的画图软件才能打开,文件属性还是文件,有没有批量操作的解决办法
      • ¥15 超时跳出方法代码的返回值问题
      • ¥15 汇编语言程序设计设计,ascii码求数,再求数的BCD码
      • ¥30 Mask rcnn训练自己的数据集出现问题!
      • ¥20 研究人工智能时的几个问题