<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ModuleFormat_List_Grid.aspx.cs" Inherits="ModuleFormat_ModuleFormat_List_Grid" Debug="true" %>
<%@ Register Src="~/Scripts/AWGridRuntime/UserControl/GridObject.ascx" TagPrefix="include" TagName="GridObject" %>
<%@ Register Src="~/Scripts/AWGridRuntime/UserControl/GridHeader.ascx" TagPrefix="include" TagName="GridHeader" %>


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <include:GridHeader runat="server" ID="GridHeader" />
<script type='text/javascript'>
var _id = 1; //id列的索引
var _sort = 5; //排序列的索引
//交换所选行位置
function swap_row(type){
    var arr = aw_arrGridSelections;
    if (arr != null) {
      var cur_index = parseInt(arr[0]);
      if(type == "up"){
        //如果当前是第一条
        if(cur_index == 0)return;
      }else{
        //如果当前是最后一条
        if(cur_index == aw_myData.length-1)return;
      }

      var text_cur = aw_myData[cur_index];
      var cur_sort = aw_myData[cur_index][_sort];

      obj.setRowSelected(false, cur_index);//取消原来行选择状态
      if(type == "up"){
          var prev_index = cur_index - 1;
          var text_prev = aw_myData[prev_index];
          var prev_sort = aw_myData[prev_index][_sort];

          aw_myData[cur_index][_sort] = prev_sort;
          aw_myData[prev_index][_sort] = cur_sort;

          aw_myData[prev_index] = text_cur;
          aw_myData[cur_index] = text_prev;

          obj.setRowSelected(true,prev_index);//选择上一行
      }else{
          var next_index = cur_index + 1;
          var text_next = aw_myData[next_index];
          var next_sort = aw_myData[next_index][_sort];

          aw_myData[cur_index][_sort] = next_sort;
          aw_myData[next_index][_sort] = cur_sort;

          aw_myData[next_index] = text_cur;
          aw_myData[cur_index] = text_next;

          obj.setRowSelected(true,next_index);//选择下一行
      }
      aw_Refresh();//刷新Grid
    }
}
</script>
</head>
<body>
    <form id="main_form" runat="server">
        <!--列表标题与样式-->
        <style type="text/css">
            <%=xview["aw_column_style"]%>
        </style>
        <!--为控件提供参数与数据-->
        <script type="text/javascript">
            <%=xview["aw_grid_info"]%>
        </script>
        <!--创建列表控件-->
        <include:GridObject runat="server" ID="GridObject" />
    </form>
</body>
</html>
