Cell Style 지정하는 방법

2008.04.08 09:13 개발언어/3rd Part
 Cell Style 지정하는 방법

방법 1 - 속성으로 제어

방법 2 - WebCombo를 사용함 또는 다른방법



내가원하는 드롭다운(데모)




버튼클릭시 이벤트



webgrid 초기화함수 (초기화시 세팅하는 부분)

        // DropDownList 클릭시 나타날 항목
        ValueList valueList = new ValueList(true);

        valueList.ValueListItems.Add(1, "test 1");
        valueList.ValueListItems.Add(2, "test 2");
        valueList.ValueListItems.Add(3, "test 3");

        valueList.DisplayStyle = ValueListDisplayStyle.DisplayText;

        this.UltraWebGrid1.DisplayLayout.Bands[0].Columns[0].Type = ColumnType.CheckBox;         //체크박스로 지정
        this.UltraWebGrid1.DisplayLayout.Bands[0].Columns[1].Type = ColumnType.Button;              //버튼으로 지정
        this.UltraWebGrid1.DisplayLayout.Bands[0].Columns[1].CellButtonDisplay = Infragistics.WebUI.UltraWebGrid.CellButtonDisplay.Always;   //버튼계속보이게 설정

        this.UltraWebGrid1.DisplayLayout.Bands[0].Columns[2].Type = ColumnType.DropDownList;    //드롭다운으로 지정

        // 클릭시 이벤트 지정 및 속성 수정가능
        this.UltraWebGrid1.DisplayLayout.CellClickActionDefault = CellClickAction.Edit;
        this.UltraWebGrid1.DisplayLayout.AllowUpdateDefault = AllowUpdate.Yes;

        // DropDownList 리스트값 대입
        this.UltraWebGrid1.DisplayLayout.Bands[0].Columns[2].ValueList = valueList;
        //this.UltraWebGrid1.DisplayLayout.Bands[0].Columns.FromKey("필드명").ValueList = valueList; //동일한 방법 (생략)


헤드클릭시 checkbox 에 모두 체크하는 js 이벤트


HOWTO:WebGrid: How to check all checkboxes in a column when the header is clicked

This article demonstrates how to loop through the WebGrid rows on the client, then set the values for checkbox cells when a header is clicked within the WebGrid.

Additional Information
The best method for setting the values for all cells in a column when the header is clicked is to handle the client-side ColumnHeaderClick event. Set the handler to be used within the property pages or in code:

In C#:

  1. UltraWebGrid1.DisplayLayout.ClientSideEvents.ColumnHeaderClickHandler = "UltraWebGrid1_ColumnHeaderClickHandler";

Within that JavaScript handler, first determine which column header was clicked by checking the Key of the column. If the key matches the desired column, loop through the rows and use the setValue() function to change the value of the cell. The following script details how this code should look:


  1. function UltraWebGrid1_ColumnHeaderClickHandler(gridName, columnId, button)
  2.     //Add code to handle your event here.
        var myCol = igtbl_getColumnById(columnId);
  3.     if (myCol.Key == "Subscriber")
  4.          var myGrid = igtbl_getGridById(gridName);
  5.          for (i = 0; i < myGrid.Rows.length; i++)
  6.          {
  7.     }
  8. }

Setting a value of 1 (to check) or 0 (to un-check) on a cell using the setValue() client-side function affects the checkbox state when the ColumnType of the column is ColumnType.CheckBox (this is declared at design-time or assigned from server-side code). If the ColumnType was not CheckBox, then setting this value onto a cell would overwrite the checkbox with the literal value '1' or '0'.





이 글은 스프링노트에서 작성되었습니다.