Hello!
I wanted to know if is it possible to add row with CommandItems ("Add new" in my case) to DetailTable like MasterTable has. What I'd like to get is the same functionality the MasterTable has, but within the DetailTable.
Any help would be appreciated, especially if there are some samples that could be helpful.
EDIT: I was able to display the EditForm inside of the DetailTable by simply adding EditFormSettings, but Update/Insert and Cancel buttons aren't visible. I also don't know how to add the CommandItem row.
I wanted to know if is it possible to add row with CommandItems ("Add new" in my case) to DetailTable like MasterTable has. What I'd like to get is the same functionality the MasterTable has, but within the DetailTable.
Any help would be appreciated, especially if there are some samples that could be helpful.
EDIT: I was able to display the EditForm inside of the DetailTable by simply adding EditFormSettings, but Update/Insert and Cancel buttons aren't visible. I also don't know how to add the CommandItem row.
4 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 06 Sep 2011, 05:16 AM
Hello Ignjat,
Try setting CommandItemDisplay in GridTableView.
aspx:
Thanks,
Princy.
Try setting CommandItemDisplay in GridTableView.
aspx:
<
DetailTables
>
<
telerik:GridTableView
CommandItemDisplay
=
"Top"
>
</
telerik:GridTableView
>
</
DetailTables
>
Thanks,
Princy.
0

Ignjat
Top achievements
Rank 1
answered on 06 Sep 2011, 10:07 AM
Hello! Thank you for the answer, I wasn't clear enough so I'll try to describe the problem better.
I have two tables in my database; one is "Company" and the second one is "Assets". I'd like my RadGrid to have loaded all the companies from the database with the DetailTable that has loaded only assets that belong to the specified company.
So, basically, I want to be able to:
1) Add a new company
2) Add a new asset to the company (I also want to have possibility to perform Update/Delete to the assets)
The new problem I'm experiencing is that my RadGrid has ItemDataBound event in which I bind data to the RadComboBoxes which belong to the "Company" table and have nothing to do with "Assets" table and whenever I click on the "Edit" button on the Assets DetailTable I get the following error: "Object reference not set to an instance of an object." which is actually related to binding the data to "Company's" RadComboBoxes.
Here is the code for the ItemDataBound event so I somehow need to recognize when DetailTable needs data binding and when MasterTable needs it:
Thank you in advance!
I have two tables in my database; one is "Company" and the second one is "Assets". I'd like my RadGrid to have loaded all the companies from the database with the DetailTable that has loaded only assets that belong to the specified company.
So, basically, I want to be able to:
1) Add a new company
2) Add a new asset to the company (I also want to have possibility to perform Update/Delete to the assets)
The new problem I'm experiencing is that my RadGrid has ItemDataBound event in which I bind data to the RadComboBoxes which belong to the "Company" table and have nothing to do with "Assets" table and whenever I click on the "Edit" button on the Assets DetailTable I get the following error: "Object reference not set to an instance of an object." which is actually related to binding the data to "Company's" RadComboBoxes.
Here is the code for the ItemDataBound event so I somehow need to recognize when DetailTable needs data binding and when MasterTable needs it:
protected void gvTicketi_ItemDataBound(object sender, GridItemEventArgs e)
{
int idFirma = Convert.ToInt16(Request.QueryString["idt"]);
if ((e.Item is GridEditFormItem) && e.Item.IsInEditMode )
{
GridEditFormItem editFormItem = (GridEditFormItem)e.Item;
UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
TSEntities db = new TSEntities();
Ticket ticket = new Ticket();
TicketAsset ticketAsset = new TicketAsset();
RadComboBox rcbTip = (RadComboBox)userControl.FindControl("rcbTip");
rcbTip.Items.Add(new RadComboBoxItem("Odaberi tip prijave"));
rcbTip.Items.Add(new RadComboBoxItem("Incident"));
rcbTip.Items.Add(new RadComboBoxItem("Reklamacija"));
rcbTip.Items.Add(new RadComboBoxItem("Nova funkcionalnost"));
rcbTip.DataBind();
RadComboBox rcbStatus = (RadComboBox)userControl.FindControl("rcbStatus");
rcbStatus.Items.Add(new RadComboBoxItem("Odaberi status prijave"));
rcbStatus.Items.Add(new RadComboBoxItem("New"));
rcbStatus.Items.Add(new RadComboBoxItem("U radu"));
rcbStatus.Items.Add(new RadComboBoxItem("On hold"));
rcbStatus.Items.Add(new RadComboBoxItem("Pending"));
rcbStatus.Items.Add(new RadComboBoxItem("Scheduled"));
rcbStatus.Items.Add(new RadComboBoxItem("Canceled"));
rcbStatus.Items.Add(new RadComboBoxItem("Completed"));
rcbStatus.DataBind();
RadComboBox rcbVrstaPrijave = (RadComboBox)userControl.FindControl("rcbVrstaPrijave");
rcbVrstaPrijave.Items.Add(new RadComboBoxItem("Odaberi vrstu prijave"));
rcbVrstaPrijave.Items.Add(new RadComboBoxItem("Usmeno"));
rcbVrstaPrijave.Items.Add(new RadComboBoxItem("Telefon"));
rcbVrstaPrijave.Items.Add(new RadComboBoxItem("E-mail"));
rcbVrstaPrijave.Items.Add(new RadComboBoxItem("Web"));
rcbVrstaPrijave.DataBind();
RadComboBox rcbPrioritet = (RadComboBox)userControl.FindControl("rcbPrioritet");
rcbPrioritet.Items.Add(new RadComboBoxItem("Odaberi prioritet prijave"));
rcbPrioritet.Items.Add(new RadComboBoxItem("Low"));
rcbPrioritet.Items.Add(new RadComboBoxItem("Normal"));
rcbPrioritet.Items.Add(new RadComboBoxItem("High"));
rcbPrioritet.Items.Add(new RadComboBoxItem("Odmah"));
rcbPrioritet.DataBind();
RadComboBox rcbNadredeniTicket = (RadComboBox)userControl.FindControl("rcbNadredeniTicket");
rcbNadredeniTicket.Items.Add(new RadComboBoxItem("Bez nadređenog ticketa", "0"));
var nadredenTicketList = (from t in db.Ticket
select t).ToList();
if (nadredenTicketList.Count > 0)
{
rcbNadredeniTicket.DataSource = from t in nadredenTicketList
where t.idFirma == idFirma && t.Zatvoren == false
select new { t.idTicket, t.idNadredeniTicket, OpisTicketa = t.idTicket + " - " + t.Opis };
rcbNadredeniTicket.DataTextField = "OpisTicketa";
rcbNadredeniTicket.DataValueField = "idTicket";
rcbNadredeniTicket.Text = "'<%# DataBinder.Eval(Container, 'DataItem.idNadredeniTicket') %>'";
}
rcbNadredeniTicket.DataBind();
RadComboBox rcbPrijavio = (RadComboBox)userControl.FindControl("rcbPrijavio");
rcbPrijavio.Items.Add(new RadComboBoxItem("Bez kontakta", "0"));
rcbPrijavio.DataSource = from k in db.Kontakt
where k.idFirma == idFirma
select new { k.idKontakt, kontaktNaziv = k.Ime + " " + k.Prezime };
rcbPrijavio.DataTextField = "kontaktNaziv";
rcbPrijavio.DataValueField = "idKontakt";
rcbPrijavio.Text = "'<%# DataBinder.Eval(Container, 'DataItem.idKontakt') %>'";
rcbPrijavio.DataBind();
RadComboBox rcbAsset = (RadComboBox)userControl.FindControl("rcbAsset");
rcbAsset.Items.Add(new RadComboBoxItem("Bez pridruženog asseta", "0"));
var assetList = (from a in db.Asset
where a.idFirma == idFirma
select a).ToList();
if (assetList.Count > 0)
{
rcbAsset.DataSource = from a in assetList
where a.idFirma == idFirma
select new { a.idAsset, a.Naziv };
rcbAsset.DataTextField = "Naziv";
rcbAsset.DataValueField = "idAsset";
rcbAsset.Text = "'<%# DataBinder.Eval(Container, 'DataItem.Naziv') %>'";
rcbAsset.DataBind();
}
if (!e.Item.OwnerTableView.IsItemInserted)
{
int idTicket = Convert.ToInt32(editFormItem.GetDataKeyValue("idTicket"));
ticket = db.Ticket.SingleOrDefault(t => t.idTicket == idTicket);
string tip = ticket.Tip;
rcbTip.Items.FindItemByText(tip).Selected = true;
string status = ticket.Status;
rcbStatus.Items.FindItemByText(status).Selected = true;
string vrstaPrijave = ticket.VrstaPrijave;
rcbVrstaPrijave.Items.FindItemByText(vrstaPrijave).Selected = true;
string prioritet = ticket.Prioritet;
rcbPrioritet.Items.FindItemByText(prioritet).Selected = true;
int kontakt = Convert.ToInt32(ticket.idKontakt);
if (ticket.idKontakt == null)
{
rcbPrijavio.Items.FindItemByValue("0").Selected = true;
}
else
{
rcbPrijavio.Items.FindItemByValue(kontakt.ToString()).Selected = true;
}
int nadredeniTicket = Convert.ToInt32(ticket.idNadredeniTicket);
if (ticket.idNadredeniTicket == ticket.idTicket)
{
rcbNadredeniTicket.Items.FindItemByValue("0").Selected = true;
}
else
{
rcbNadredeniTicket.Items.FindItemByValue(nadredeniTicket.ToString()).Selected = true;
}
var ticketAssetCount = from ta in db.TicketAsset
where ta.idTicket == idTicket
select ta;
if (ticketAssetCount.Count() > 0)
{
ticketAsset = db.TicketAsset.SingleOrDefault(ta => ta.idTicket == idTicket);
int asset = Convert.ToInt32(ticketAsset.idAsset);
rcbAsset.Items.FindItemByValue(asset.ToString()).Selected = true;
}
else
{
rcbAsset.Items.FindItemByValue("0").Selected = true;
}
}
}
}
Thank you in advance!
0

Ignjat
Top achievements
Rank 1
answered on 06 Sep 2011, 03:23 PM
Excuse me for bumping the post, but I need some help with it and it is quite urgent.
0
Hi Ignjat,
When perfoming actions in the detail table on ItemDataBound you should also check which is the OwnerTableView of e.Item.
Regards,
Tsvetina
the Telerik team
When perfoming actions in the detail table on ItemDataBound you should also check which is the OwnerTableView of e.Item.
protected
void
RadGrid1_ItemDataBound(
object
sender, Telerik.Web.UI.GridItemEventArgs e)
{
//identify to which table belongs the currently bound item, the Name property of the GridTableView should be explicitly set
if
(e.Item.OwnerTableView.Name ==
"MyUniqueTableName"
)
{
//process requested operations
}
}
Regards,
Tsvetina
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>