Pergunta

Eu quero fazer os itens da minha RadGrid ser editável no carregamento da página. Eu tentei ambos os métodos aqui http://www.telerik.com/help /aspnet/grid/grddefaulteditmodeforgriditemsoninitialload.html mas também não tem qualquer efeito.

O 2º método por exemplo, mostrado abaixo, onde a propriedade Editar é definida no evento ItemCreated, faz com que o modo de edição a ser definida true (verificada por depurador), mas não tem efeito sobre os resultados quando a página é exibida.

Alguém tem alguma idéia do que estou fazendo de errado?

protected void RadGrid1_ItemCreated(object sender, Telerik.WebControls.GridItemEventArgs e)
{
    if (!Page.IsPostBack && e.Item is GridEditableItem)
   {
       e.Item.Edit = true;
   }
}
Foi útil?

Solução

Isso funciona:

for (int i = 0; i < RadGrid1.PageSize; i++)
{
    RadGrid1.EditIndexes.Add(i);
    RadGrid1.Rebind();
}

Outras dicas

Isso também funciona:

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    e.Item.Edit = true;
}

O código a seguir pode ser usado se você gostaria de fazer, como descrito acima, mas para tabelas filho:

protected void RadGrid1_PreRender(object sender, EventArgs e)  
{  
    foreach (GridDataItem item in RadGrid1.MasterTableView.Items)  
    {  
        if (item.HasChildItems)  
        {  
            GridTableView childTable = (GridTableView)item.ChildItem.NestedTableViews[0];  


            foreach (GridDataItem childitem in childTable.Items)  
            {  

               //Check for the newly inserted row 
               //and set in edit mode 
               //childitem.Edit=true; 
            }  
        }  
    }  
    RadGrid1.MasterTableView.Rebind();  
}  
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top