PDA

View Full Version : [CLOSED] Refresh issue with AccordionLayout panel.



bossun
Sep 17, 2012, 5:52 PM
Hi,

I have an refreshing issue when using a AccordionLayout panel on "SecurityPanel".

The collapsed element doesn't display (at first page load) selected rows on Gridpanels until it have been expanded once.

Is it a bug or a normal behavior?


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Users.aspx.cs" Inherits="Web_Users" Title="<%$ Resources:Resource,Users %>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

<script type="text/javascript">
Ext.grid.PropertyColumnModel.override({
nameText: '<asp:Literal runat="server" Text="<%$ Resources:Resource, Property %>" />',
valueText: '<asp:Literal runat="server" Text="<%$ Resources:Resource, Value %>" />',
trueText: '<asp:Literal runat="server" Text="<%$ Resources:Resource, Yes %>" />',
falseText: '<asp:Literal runat="server" Text="<%$ Resources:Resource, No %>" />'
});

var yesVar = '<asp:Literal runat="server" Text="<%$ Resources:Resource, Yes %>" />';
var noVar = '<asp:Literal runat="server" Text="<%$ Resources:Resource, No %>" />';
</script>


<ext:XScript runat="server">
<script type="text/javascript">
var Init = function() {


#{UsersFormEditor}.getForm().reset();
#{btnDelete}.setDisabled(true);
#{UsersGrid}.getSelectionModel().deselectAll(true) ;


#{PropertyGrid1}.removeAll();

#{RolesGridPanel}.suspendEvents();
#{RolesGridPanel}.store.removeAll();
#{RolesGridPanel}.resumeEvents();

#{RefereeLeagueQualificationGridPanel}.suspendEven ts();
#{RefereeLeagueQualificationGridPanel}.getSelectio nModel().deselectAll(true)
#{RefereeLeagueQualificationGridPanel}.resumeEvent s();
}

var AttrbuteRender = function(value){

var r = #{UserAttributesStoreID}.getById(value);

if (Ext.isEmpty(r)) {
return value;
}
return r.data.TRANSLATEDVALUE;
}

var booleanPropertyRenderer = function(value){


if (value == true)
{
return yesVar;
}
else if (value == false)
{
return noVar;
}
}


var UserRowSelectionChenage = function(sender,record,options){

if(record[0]==null)
return;


var UserId = record[0].getId();

SetSelectedRoles(UserId);
App.direct.LoadLeaguesForReferee(UserId);
}


var SaveRoles = function(){
var usersGrd = #{UsersGrid};
var UserSm = usersGrd.getSelectionModel();
var RoleSm = #{RolesGridPanel}.getSelectionModel();

UserSm.setLocked(true);

var Role = RoleSm.getSelection();
var UserId = UserSm.getLastSelected().getId();
var RolesId = new Array();

for(i=0;i<Role.length;i++)
{
RolesId[i] = Role[i].getId();
}

App.direct.SaveRoles(UserId,RolesId);

UserSm.setLocked(false);
}

function SetSelectedRoles(userId){

#{RolesGridPanel}.suspendEvents();

#{RolesGridPanel}.getSelectionModel().deselectAll( true)
App.direct.LoadRolesForUser(userId);

#{RolesGridPanel}.resumeEvents();

}


</script>
</ext:XScript>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:ResourceManager runat="server"/>

<asp:ObjectDataSource ID="CountryDataSource" runat="server" SelectMethod="CountrySelect"
TypeName="Sigmasport.Code.BusinessLayer.SigmaSportCountry">
<SelectParameters>
<asp:ProfileParameter Name="CULTURE" PropertyName="CULTURE" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>

<asp:ObjectDataSource ID="RolesDataSource" runat="server" SelectMethod="SelectAllRoles"
TypeName="Sigmasport.Code.BusinessLayer.SigmaSportUser">
<SelectParameters>
<asp:ProfileParameter Name="CULTURE" PropertyName="CULTURE" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>

<asp:ObjectDataSource ID="UsersDataSource" runat="server" SelectMethod="UserSelect" TypeName="Sigmasport.Code.BusinessLayer.SigmaSportUser"/>

<asp:ObjectDataSource ID="UserAttributeDataSource" runat="server" SelectMethod="UserAttributeSelect" TypeName="Sigmasport.Code.BusinessLayer.SigmaSportUserAttrib ute">
<SelectParameters>
<asp:ProfileParameter Name="CULTURE" PropertyName="CULTURE" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>

<asp:ObjectDataSource ID="LeagueDataSource" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="LeagueSelect" TypeName="Sigmasport.Code.BusinessLayer.SigmaSportLeague">
</asp:ObjectDataSource>

<%-- STORES --%>
<ext:Store ID="CountriesStoreID" runat="server" DataSourceID="CountryDataSource">
<Model>
<ext:Model runat="server" IDProperty="COUNTRYCODE">
<Fields>
<ext:ModelField Name="COUNTRYCODE" Type="String" />
<ext:ModelField Name="DEFAULTNAME" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>

<ext:Store ID="RolesStoreID" runat="server" DataSourceID="RolesDataSource">
<Model>
<ext:Model ID="Model1" runat="server" IDProperty="ROLE">
<Fields>
<ext:ModelField Name="ROLE" />
</Fields>
</ext:Model>
</Model>
</ext:Store>

<ext:Store ID="UsersStoreID" runat="server" DataSourceID="UsersDataSource"
>
<Model>
<ext:Model runat="server" IDProperty="ID">
<Fields>
<ext:ModelField Name="ID" Type="Int" />
<ext:ModelField Name="NATIONALITY" Type="String" />
<ext:ModelField Name="FIRSTNAME" Type="String" />
<ext:ModelField Name="LASTNAME" Type="String" />
<ext:ModelField Name="ADDRESS" Type="String" />
<ext:ModelField Name="ZIP" Type="String" />
<ext:ModelField Name="LOCALITY" Type="String" />
<ext:ModelField Name="EMAIL" Type="String" />
<ext:ModelField Name="PRIVATPHONE" Type="String" />
<ext:ModelField Name="MOBILEPHONE" Type="String" />
<ext:ModelField Name="WORKPHONE" Type="String" />
<ext:ModelField Name="BIRTHDATE" Type="Date" />
<ext:ModelField Name="PICTURE" Type="String" />
<ext:ModelField Name="DISABLED" Type="Boolean" />
<ext:ModelField Name="LOCKED" Type="Boolean" />
<ext:ModelField Name="USERID_MEMBERSHIP" Type="String" />
<ext:ModelField Name="MODIFIEDBY" Type="String" />
<ext:ModelField Name="TIMESTAMP" Type="Date" />
</Fields>
</ext:Model>
</Model>
</ext:Store>

<ext:Store ID="UserAttributesStoreID" runat="server" DataSourceID="UserAttributeDataSource">
<Model>
<ext:Model runat="server" IDProperty="ID">
<Fields>
<ext:ModelField Name="ID" Type="Int" />
<ext:ModelField Name="ATTRIBUTENAME" Type="String" />
<ext:ModelField Name="TRANSLATEDVALUE" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>

<ext:Store ID="CustomAttributesStoreID" runat="server">
<Model>
<ext:Model runat="server" IDProperty="ATTRIBUTEID">
<Fields>
<ext:ModelField Name="ATTRIBUTEID" Type="Int" />
<ext:ModelField Name="VALUE" Type="String" />
<ext:ModelField Name="DATATYPE" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>

<ext:Store ID="LeagueStoreID" runat="server" DataSourceID="LeagueDataSource" GroupDir="ASC" GroupField="LEVEL">
<Model>
<ext:Model runat="server" IDProperty="ID">
<Fields>
<ext:ModelField Name="ID" Type="Int" />
<ext:ModelField Name="NAME" Type="String" />
<ext:ModelField Name="LEVEL" Type="Int" />
<ext:ModelField Name="TRANSLATEDVALUE" type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>

<%-- END STORES --%>
<ext:Viewport ID="Viewport1" runat="server" Layout="border" Padding="5">
<Items>

<ext:GridPanel ID="UsersGrid"
runat="server"
Title="<%$ Resources:Resource,Users %>"
StoreID="UsersStoreID"
StripeRows="true"
Icon="UserSuit"
Region="Center"
Frame="true">
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column runat="server" DataIndex="ID" Text="<%$ Resources:Resource,ID %>" Hidden="true"/>
<ext:Column runat="server" DataIndex="FIRSTNAME" Text="<%$ Resources:Resource,FirstName %>" Flex="2" />
<ext:Column runat="server" DataIndex="LASTNAME" Text="<%$ Resources:Resource,LastName %>" Flex="2" />
<ext:Column runat="server" DataIndex="EMAIL" Text="<%$ Resources:Resource,Email %>" Flex="2" />
<ext:CheckColumn runat="server" DataIndex="DISABLED" Text="<%$ Resources:Resource,Disabled %>" Flex="1" />
<ext:CheckColumn runat="server" DataIndex="LOCKED" Text="<%$ Resources:Resource,Locked %>" Flex="1" />
</Columns>
</ColumnModel>
<Features>
<ext:GridFilters runat="server" ID="UsersGridFilter1" Local="true">
<Filters>
<ext:NumericFilter DataIndex="ID" />
<ext:StringFilter DataIndex="FIRSTNAME" />
<ext:StringFilter DataIndex="LASTNAME" />
<ext:BooleanFilter DataIndex="DISABLED" />
<ext:BooleanFilter DataIndex="LOCKED" />
</Filters>
</ext:GridFilters>
</Features>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
<SelectedRows>
<ext:SelectedRow RowIndex="0" />
</SelectedRows>
<Listeners>
<SelectionChange Fn="UserRowSelectionChenage" />
</Listeners>
<DirectEvents>
<Select OnEvent="RowSelect" Buffer="250">
<ExtraParams>
<ext:Parameter Name="ID" Value="record.getId()" Mode="Raw" />
</ExtraParams>
</Select>
</DirectEvents>
</ext:RowSelectionModel>
</SelectionModel>
<BottomBar>
<ext:PagingToolbar ID="PagingToolbar1" runat="server" />
</BottomBar>
</ext:GridPanel>

<ext:TabPanel
runat="server"
ID="MainTabPanel"
Split="true"
Width="400"
Region="East">
<Items>
<ext:FormPanel ID="UsersFormEditor" runat="server" Frame="true" Padding="5" BodyPadding="5"
Title="<%$ Resources:Resource,UserEditor %>" AutoScroll="true" Icon="User" MonitorValid="true"
DefaultAnchor="100%">
<Items>
<ext:Hidden ID="ID" runat="server" DataIndex="ID">
</ext:Hidden>
<ext:TextField ID="FIRSTNAME" runat="server" DataIndex="FIRSTNAME" FieldLabel="<%$ Resources:Resource,FirstName %>"
MsgTarget="Side" AllowBlank="false" />
<ext:TextField ID="LASTNAME" runat="server" DataIndex="LASTNAME" FieldLabel="<%$ Resources:Resource,LastName %>"
MsgTarget="Side" AllowBlank="false" />
<ext:TextField ID="ADDRESS" runat="server" DataIndex="ADDRESS" FieldLabel="<%$ Resources:Resource,Address %>" />
<ext:TextField ID="ZIP" runat="server" DataIndex="ZIP" FieldLabel="<%$ Resources:Resource,Zip %>" />
<ext:TextField ID="LOCALITY" runat="server" DataIndex="LOCALITY" FieldLabel="<%$ Resources:Resource,Locality %>" />
<ext:ComboBox ID="NATIONALITY" runat="server" StoreID="CountriesStoreID" ValueField="COUNTRYCODE"
DisplayField="DEFAULTNAME" FieldLabel="<%$ Resources:Resource,Nationality %>" />
<ext:TextField ID="EMAIL" runat="server" DataIndex="EMAIL" FieldLabel="<%$ Resources:Resource,Email %>"
MsgTarget="Side" AllowBlank="false" Vtype="email" EmptyText="<%$ Resources:Resource,RequestValidEmail %>" />
<ext:TextField ID="PRIVATEPHONE" runat="server" DataIndex="PRIVATEPHONE" FieldLabel="<%$ Resources:Resource,PrivatePhone %>" />
<ext:TextField ID="MOBILEPHONE" runat="server" DataIndex="MOBILEPHONE" FieldLabel="<%$ Resources:Resource,MobilePhone %>" />
<ext:TextField ID="WORKPHONE" runat="server" DataIndex="WORKPHONE" FieldLabel="<%$ Resources:Resource,WorkPhone %>" />
<ext:DateField ID="BIRTHDATE" runat="server" DataIndex="BIRTHDATE" FieldLabel="<%$ Resources:Resource,BirthDate %>" />
<ext:Checkbox ID="DISABLED" runat="server" DataIndex="DISABLED" FieldLabel="<%$ Resources:Resource,Disabled %>" />
<ext:Checkbox ID="LOCKED" runat="server" DataIndex="LOCKED" FieldLabel="<%$ Resources:Resource,Locked %>" />
<%--<ext:FieldSet runat="server" Layout="RowLayout" CollapseFirst="true" Collapsible="true" Title="<%$ Resources:Resource,Picture %>">
<Items>

<ext:FileUploadField ID="PICTURE" runat="server" Width="150" ButtonOnly="false" Icon="PictureAdd" ButtonText=""/>
</Items>
</ext:FieldSet>--%>
<ext:Image ID="imgPicture" runat="server" Resizable="false" Height="200">
</ext:Image>
<ext:FieldSet ID="fAudit" runat="server" Collapsible="true" Collapsed="true" Title="<%$ Resources:Resource,Audit %>">
<Items>
<ext:DisplayField ID="MODIFIEDBY" runat="server" DataIndex="MODIFIEDBY" FieldLabel="<%$ Resources:Resource,ModifiedBy %>" />
<ext:Container ID="Container1" runat="server">
</ext:Container>
<ext:DisplayField ID="TIMESTAMP" runat="server" DataIndex="TIMESTAMP" FieldLabel="<%$ Resources:Resource,TimeStamp %>" />
</Items>
</ext:FieldSet>
</Items>
<Listeners>
<ValidityChange Handler="#{btnSave}.setDisabled(!valid);" />
</Listeners>
</ext:FormPanel>

<ext:Panel ID="SecurityPanel" runat="server" Frame="true" Icon="DatabaseKey" Padding="5"
Title="<%$ Resources:Resource,RolesAndSecurity %>" Layout="AccordionLayout">
<Items>

<ext:GridPanel ID="RolesGridPanel" runat="server" StoreID="RolesStoreID" Frame="true"
Icon="LockKey" Title="<%$ Resources:Resource,Roles %>" Padding="5">
<ColumnModel ID="ColumnModel2" runat="server">
<Columns>
<ext:Column runat="server" DataIndex="ROLE" Text="<%$ Resources:Resource,Id %>" Hidden="true" />
<ext:Column runat="server" DataIndex="ROLE" Flex="1" />
</Columns>
</ColumnModel>
<Listeners>
<SelectionChange Fn="SaveRoles" Buffer="250" />
</Listeners>
<SelectionModel>
<ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server" CheckOnly="true" />
</SelectionModel>
</ext:GridPanel>

<ext:Panel ID="RefereePanel"
Title="RefereeQualifications"
Icon="SportShuttlecock"
runat="server"
Layout="FitLayout">
<Items>
<ext:GridPanel ID="RefereeLeagueQualificationGridPanel"
runat="server"
Frame="true"
Region="Center"
StoreID="LeagueStoreID"
Padding="5">
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" DataIndex="ID" Visible="false" />
<ext:Column runat="server" DataIndex="TRANSLATEDVALUE" Visible="true" Flex="2" Text="<%$ Resources:Resource,League %>" />
<ext:Column runat="server" Text="<%$ Resources:Resource,Level %>" DataIndex="LEVEL" GroupName="<%$ Resources:Resource,HierarchicalLevel %>"></ext:Column>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:CheckboxSelectionModel runat="server" CheckOnly="true" Mode="Multi"></ext:CheckboxSelectionModel>
</SelectionModel>
<Features>
<ext:Grouping runat="server" HideGroupedHeader="true" EnableNoGroups="false"></ext:Grouping>
</Features>
</ext:GridPanel>
</Items>
</ext:Panel>
</Items>
</ext:Panel>


<ext:Panel ID="AdditionalDataPanel" runat="server" Icon="TableKey" Layout="FitLayout"
Title="<%$ Resources:Resource,AdditionalData %>">
<Items>
<ext:PropertyGrid runat="server" ID="PropertyGrid1" Frame="true" Header="false" Layout="FitLayout">
<Source>
<ext:PropertyGridParameter Name="init" />
</Source>
</ext:PropertyGrid>
</Items>
</ext:Panel>


</Items>
<TopBar>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:Button ID="btnInit"
runat="server"
Text="<%$ Resources:Resource,Initialise %>"
Icon="Add">
<Listeners>
<Click Fn="Init" />
</Listeners>
</ext:Button>
<ext:Button ID="btnSave"
runat="server" FormBind="true"
Text="<%$ Resources:Resource,Save %>"
Icon="DiskEdit">
<DirectEvents>
<Click OnEvent="SaveData" Buffer="250">
<ExtraParams>
<ext:Parameter Name="UserRecord" Mode="Raw" Value="#{UsersFormEditor}.getForm().getValues()"></ext:Parameter>
</ExtraParams>
</Click>
</DirectEvents>
</ext:Button>
<ext:Button ID="btnDelete"
runat="server"
Text="<%$ Resources:Resource,Delete %>"
Icon="Delete"
Disabled="true"
>
<DirectEvents>
<Click OnEvent="DeleteData" Buffer="250">
<Confirmation Message="<%$ Resources:Resource,M_Confirm_Delete %>" ConfirmRequest="true" />
<ExtraParams>
<ext:Parameter Name="UserRecord" Mode="Raw" Encode="true" Value="#{UsersFormEditor}.getForm().getValues()" />
</ExtraParams>
</Click>
</DirectEvents>
</ext:Button>
<ext:ToolbarSeparator ID="ToolbarSeparator1" runat="server" />
</Items>
</ext:Toolbar>
</TopBar>
</ext:TabPanel>

</Items>
</ext:Viewport>

</div>
</form>
</body>
</html>


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;
using System.Data.Common;
using System.Data;
using Sigmasport.Code.BusinessLayer;
using System.IO;
using Sigmasport.Code.Shared;
using Resources;

public partial class Web_Users : Sigmasport.Code.Shared.SigmaSportPage
{

protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
}

}

protected override void RowSelect(object sender, DirectEventArgs e)
{
btnDelete.Disabled = false;
RolesStoreID.DataBind();

int id = Convert.ToInt32(e.ExtraParams["ID"]);

LoadDetails(id);
//LoadRolesForUser(id);
//LoadLeaguesForReferee(id);
LoadCustomAttributes(id);
}

protected void BtnSaveUser_Click(object sender, DirectEventArgs e)
{
#region Save Picture
//if (PICTURE.HasFile)
//{
// if (PICTURE.PostedFile.ContentType == "image/gif" || PICTURE.PostedFile.ContentType == "image/png"
// || PICTURE.PostedFile.ContentType == "image/jpg" || PICTURE.PostedFile.ContentType == "image/jpeg")
// {
// string fileExt = Path.GetExtension(PICTURE.FileName);
// string FileName = string.Format(@"{0}{1}",ID, fileExt);
// PICTURE.PostedFile.SaveAs(HttpRuntime.AppDomainApp Path + @"Resources\UserPictures\" + FileName);

// SigmaSportUser.UserUpdatePicturePath(Convert.ToInt 32(ID), FileName);

//}

#endregion


}

//protected void LoadRefereeDetails(int USERID)
//{
// DataTable dt = SigmaSportUser.UserSelect_RefereeDetail(USERID);

// foreach (DataRow dr in dt.Rows)
// {
// RefereeDataPanel.SetValues(new {
// USERID = "",
// CLUBID = "",
// REFERENCECONVOCATORID = "",
// LICENSE = "",
// CAR = "",
// SKATE = "",
// INTERNATIONAL=""
// });
// }
//}

protected override void LoadDetails(int ID)
{
DataTable dtUsers = SigmaSportUser.UserSelect(ID);

UsersFormEditor.SetValues(new { }) ;


foreach (DataRow r in dtUsers.Rows)
{
UsersFormEditor.SetValues(new
{
ID = r["ID"]
,FIRSTNAME = r["FIRSTNAME"]
,LASTNAME = r["LASTNAME"]
,ADDRESS = r["ADDRESS"]
,ZIP = r["ZIP"]
,LOCALITY = r["LOCALITY"]
,EMAIL = r["EMAIL"]
,PRIVATEPHONE = r["PRIVATEPHONE"]
,MOBILEPHONE = r["MOBILEPHONE"]
,WORKPHONE = r["WORKPHONE"]
,BIRTHDATE = r["BIRTHDATE"]
,PICTURE = r["PICTURE"]
,DISABLED = r["DISABLED"]
,LOCKED = r["LOCKED"]
,MODIFIEDBY = r["MODIFIEDBY"]
,TIMESTAMP = r["TIMESTAMP"]
,NATIONALITY = r["NATIONALITY"]

});
imgPicture.ImageUrl = @"..\Resources\UserPictures\" + r["PICTURE"].ToString();
}

}

protected override void DeleteData(object sender, DirectEventArgs e)
{

try
{
Dictionary<string, object> UserRecord = JSON.Deserialize<Dictionary<string, object>>(e.ExtraParams["UserRecord"]);

ExecuteMethod(UserRecord, typeof(SigmaSportUser), "UserDelete");

UsersStoreID.DataBind();
UsersFormEditor.Reset();

btnDelete.Disable();
}
catch (Exception ex)
{
if(ex.InnerException != null)
ErrorBox(ex.InnerException.Message);
else
ErrorBox(ex.Message);

}
}

protected override void SaveData(object sender, DirectEventArgs e)
{
Dictionary<string, object> UserRecord = JSON.Deserialize<Dictionary<string, object>>(e.ExtraParams["UserRecord"]);
bool Update = true;
try
{
object UserId = UserRecord["ID"];
if (UserId.ToString() == string.Empty)
{
UserId = ExecuteMethod(UserRecord, typeof(SigmaSportUser), "UserInsert");
Update = false;
}
else
UserId = ExecuteMethod(UserRecord, typeof(SigmaSportUser), "UserUpdate");


UsersGrid.SuspendEvents();

SaveCustomProperties(Convert.ToInt32(UserId));

UsersStoreID.DataBind();
SetRowSelected(UsersGrid, UserId);

UsersGrid.ResumeEvents();

if (Update)
ShowNotification(Resource.M_Notif_ItemUpdated);
else
ShowNotification(Resource.M_Notif_ItemCreated);
}
catch (Exception ex)
{
ErrorBox(ex.InnerException.Message);

}
}

[DirectMethod]
public void LoadRolesForUser(int ID)
{
List<string> SelectedRoles = new List<string>(SigmaSportUser.SelectRolesForUser(ID));


RowSelectionModel sm = RolesGridPanel.GetSelectionModel() as RowSelectionModel;

//RolesGridPanel.SuspendEvents();

sm.SelectedRows.Clear();

foreach (string r in SelectedRoles)
{
sm.SelectedRows.Add(new SelectedRow(r));
}

sm.UpdateSelection();

//RolesGridPanel.ResumeEvents();

}

[DirectMethod(ShowMask = true, Target = MaskTarget.CustomTarget, CustomTarget = "MainTabPanel")]
//[DirectMethod]
public void LoadLeaguesForReferee(int USERID)
{
DataTable leagues = SigmaSportUser.UserSelect_RefereeLeaguequalificati on(USERID);

RowSelectionModel rsm = RefereeLeagueQualificationGridPanel.GetSelectionMo del() as RowSelectionModel;

RefereeLeagueQualificationGridPanel.SuspendEvents( );

rsm.SelectedRows.Clear();

foreach (DataRow dr in leagues.Rows)
{
rsm.SelectedRows.Add(new SelectedRow(dr["LEAGUEID"].ToString()));
}
rsm.UpdateSelection();
RefereeLeagueQualificationGridPanel.ResumeEvents() ;
}

[DirectMethod(ShowMask = true, Target = MaskTarget.CustomTarget, CustomTarget = "MainTabPanel")]
//[DirectMethod]
public void SaveRoles(int USERID,string[] Roles)
{

try
{
List<string> CurrentRoles = new List<string>(SigmaSportUser.SelectRolesForUser(USERID));
List<string> NewRoles = new List<string>(Roles);
//Roles to Remove
foreach (string r in CurrentRoles)
{
if (!NewRoles.Contains(r))
{
SigmaSportUser.DeleteUserFromRole(USERID, r);
ShowWarning(string.Format(Resource.M_Notif_RoleRem oved, r));
}
}

//Save New Roles
foreach (string r in NewRoles)
{
if (!CurrentRoles.Contains(r))
{
SigmaSportUser.AddUserToRole(USERID, r);
ShowNotification(string.Format(Resource.M_Notif_Ro leAdded,r));
}
}

LoadCustomAttributes(USERID);
}
catch (Exception ex)
{
ErrorBox(ex.Message);
}
}

[DirectMethod]
public void LoadCustomAttributes(int USERID)
{
DataTable dt = SigmaSportUser.UserSelect_AllCutomAttributes(USERI D);
DataTable attr = SigmaSportUserAttribute.UserAttributeSelect(Profil e.CULTURE);

PropertyGrid1.Source.Clear();

Field Editor = null;
foreach(DataRow dr in dt.Rows)
{
PropertyGridParameter p = new PropertyGridParameter();
p.Name = dr["ATTRIBUTEID"].ToString();
DataRow[] drAttr = attr.Select(string.Format("ID={0}", p.Name));


if (drAttr.Length > 0)
{
p.DisplayName = drAttr[0]["TRANSLATEDVALUE"].ToString();
}

p.Value = dr["VALUE"].ToString();

switch (dr["DATATYPE"].ToString())
{
case "DateTime":
{
DateField DF = new DateField();
DF.Format = "dd MMM yyyy";
Editor = DF;
break;
}
case "Boolean":
{

Checkbox cb = new Checkbox();

p.Renderer.Fn = "booleanPropertyRenderer";

Editor = cb;
break;
}
case "Numeric":
{
NumberField nf = new NumberField();
nf.DecimalPrecision = 4;
Editor = nf;
break;
}
case "List":
{
break;
}
default:
{
TextField tf = new TextField();
Editor = tf;
break;
}
}

p.Editor.Add(Editor);
PropertyGrid1.Source.Add(p);
}

PropertyGrid1.Render();
}

void SaveCustomProperties(int USERID)
{
foreach (PropertyGridParameter p in PropertyGrid1.Source)
{
if (p.Name != "init")
{

SigmaSportUser.UserUpdate_CutomAttribute(USERID, Convert.ToInt32(p.Name), p.Value);
}
}

}

}

Daniil
Sep 17, 2012, 6:45 PM
Hi,

Unfortunately, I cannot run the sample because it throws the Exception.



The collapsed element doesn't display (at first page load) selected rows on Gridpanels until it have been expanded once.


Please clarify what exactly GridPanel do you mean? How do you select the rows?

Generally, any rows should be selected after GridPanel rendering. Any initially hidden accordion items are not rendered.

bossun
Sep 17, 2012, 9:31 PM
Hi,
Generally, any rows should be selected after GridPanel rendering. Any initially hidden accordion items are not rendered.

Ok I understand now.

So I moved my code in client side and it works perfectly.

Thank you for your help.