Infragistics Community Forum / Web / Ultimate UI for ASP.NET Web Forms / Getting Client Id of Selected Row in JavaScript
Getting Client Id of Selected Row in JavaScript
New DiscussionHi,
How can i get the Client Id of selected row through javascript. Here is my JavaScript Code
function dgAllocation_CellEditing_ExitedEditMode(sender, eventArgs)
{
var grid = $find("<%=dgAllocation.ClientID%>");
var gridBehaviors = grid.get_behaviors();
var row = gridBehaviors.get_selection().get_selectedRows().getItem(0);
alert(row);
var rowId = row.get_index();
}
I need clientId instead of rowIndex.
Replies
-
0
Hello,
Thank you for using our forum.
Rows do not have client id, you can get data key with the row.get_dataKey(), which returns the data key value of the row.
Can you please explain in more details what is the behavior you want to achieve.
Let me know if I may be of further assistance.
-
0
Actually I needed the selected Row Index. I found the solution in the Forum. Thanks for your reply. I have another question.
I am converting an Ultrawebgrid to Webdatagrid .There are six columns out of which two are dropdown and rest are textbox. During editing a row when I do not select
any items from the dropdown and update the values of other textboxes it gives me the text of the dropdown instead of value which is a GUID and throws an exception
"Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)". I need the GUID not the text. But when I go to select an item from the dropdown it gives me the value that is GUID. I could not figure out how to resolve it. Please help. Below is my code.
Javascript Code:
function dgAllocation_CellEditing_ExitedEditMode(sender, eventArgs) {
var grid = $find("<%=dgAllocation.ClientID%>");var gridBehaviors = grid.get_behaviors();
var row = gridBehaviors.get_selection().get_selectedRows().getItem(0);
alert(row);
var rowId = row.get_index();abmAPI.updateAllocations(rowId,
eventArgs.getCell().get_row().get_cellByColumnKey("AL_ID").get_value(),
eventArgs.getCell().get_row().get_cellByColumnKey("MI_YEAR").get_value(),
eventArgs.getCell().get_row().get_cellByColumnKey("CC_NAME").get_value(), ///dropdown
eventArgs.getCell().get_row().get_cellByColumnKey("AL_ACCTTYPE").get_value(),
eventArgs.getCell().get_row().get_cellByColumnKey("AL_ACCTPATTERN").get_value(),
eventArgs.getCell().get_row().get_cellByColumnKey("AL_DESTPATTERN").get_value(),
eventArgs.getCell().get_row().get_cellByColumnKey("ST_NUM").get_value(), ///dropdown
eventArgs.getCell().get_row().get_cellByColumnKey("AL_TIMING").get_value()!=null?eventArgs.getCell().get_row().get_cellByColumnKey("AL_TIMING").get_value():"1",
updateAllocationsHandler);}
Dropdown:
<EditorProviders>
<ig:DropDownProvider ID="AllocationTypeProvider"><EditorControl DisplayMode="DropDownList" DropDownContainerMaxHeight="200px" TextField="ST_NAME"
ValueField="ST_ID" EnableAnimations="False" EnableDropDownAsChild="False" ClientIDMode="Predictable"
ID="EditorControl1">
<DropDownItemBinding TextField="ST_NAME" ValueField="ST_ID"></DropDownItemBinding>
</EditorControl>
</ig:DropDownProvider>
<ig:DropDownProvider ID="FromTypeProvider"><EditorControl DisplayMode="DropDownList" DropDownContainerMaxHeight="200px" EnableAnimations="False"
EnableDropDownAsChild="False" ClientIDMode="Predictable" ID="EditorControl2">
</EditorControl>
</ig:DropDownProvider>
<ig:DropDownProvider ID="FromCCProvider"><EditorControl DisplayMode="DropDownList" DropDownContainerMaxHeight="200px" TextField="CC_NAME"
ValueField="CC_ID" EnableAnimations="False" EnableDropDownAsChild="False" ClientIDMode="Predictable"
ID="EditorControl3">
<DropDownItemBinding TextField="CC_NAME" ValueField="CC_ID"></DropDownItemBinding>
</EditorControl>
</ig:DropDownProvider>
</EditorProviders>How to update the value in only that cell which are active and set the GUID instead of text of the dropdown?
-
0
Hello,
However I was not able to reproduce the behaviour that you're seeing on your side. When I call get_value() the cell value is returned not the text.
I have attached the sample project I used to test this. Please test this project on your side; whether or not it works correctly may help indicate the nature of this issue.
If this sample project is not an accurate demonstration of what you're trying to do, please feel free to modify it and send it back, or send a small sample project of your own if you have one.
Please let me know if I can provide any further assistance.
-
0
Hi Nadia…
Here is my code.I am still getting the same error.When the dropdown column is in editable mode it do not throw error.But it throws error only when we do not touch the dropdown column and update the value in any other column in the same row..It stores the text in variable " fromCC " in function "UpdateAllocation()" (mentioned below) which is a GUID and hence throws an exception.
Allocation.aspx
————————
function dgAllocation_CellEditing_ExitedEditMode(sender, eventArgs) {
var grid = $find("<%=dgAllocation.ClientID%>");
var gridBehaviors = grid.get_behaviors();
var row = gridBehaviors.get_selection().get_selectedRows().getItem(0);
var rowId = row.get_index();
abmAPI.updateAllocations(rowId,
eventArgs.getCell().get_row().get_cellByColumnKey("AL_ID").get_value(),
eventArgs.getCell().get_row().get_cellByColumnKey("MI_YEAR").get_value(),
eventArgs.getCell().get_row().get_cellByColumnKey("CC_NAME").get_value(),
eventArgs.getCell().get_row().get_cellByColumnKey("AL_ACCTTYPE").get_value(),
eventArgs.getCell().get_row().get_cellByColumnKey("AL_ACCTPATTERN").get_value(),
eventArgs.getCell().get_row().get_cellByColumnKey("AL_DESTPATTERN").get_value(),
eventArgs.getCell().get_row().get_cellByColumnKey("ST_NUM").get_value(),
eventArgs.getCell().get_row().get_cellByColumnKey("AL_TIMING").get_value() != null ? eventArgs.getCell().get_row().get_cellByColumnKey("AL_TIMING").get_value() : "1",
updateAllocationsHandler);
}
<Behaviors>
<ig:EditingCore AutoCRUD="False" BatchUpdating="True">
<Behaviors>
<ig:CellEditing>
<ColumnSettings>
<ig:EditingColumnSetting ColumnKey="Notes" ReadOnly="True" />
<ig:EditingColumnSetting ColumnKey="MI_YEAR" ReadOnly="True" />
<ig:EditingColumnSetting ColumnKey="CC_ID" ReadOnly="True" />
<ig:EditingColumnSetting ColumnKey="CC_NAME" ReadOnly="False" EditorID="FromCCProvider" />
<ig:EditingColumnSetting ColumnKey="AL_ACCTTYPE" ReadOnly="False" EditorID="FromTypeProvider" />
<ig:EditingColumnSetting ColumnKey="AL_ACCTPATTERN" ReadOnly="False" />
<ig:EditingColumnSetting ColumnKey="AL_DESTPATTERN" ReadOnly="False" />
<ig:EditingColumnSetting ColumnKey="AL_ALLOCTYPE" ReadOnly="False" />
<ig:EditingColumnSetting ColumnKey="ST_NUM" ReadOnly="False" EditorID="AllocationTypeProvider" ValidatorID="RequiredFieldValidator1" />
<ig:EditingColumnSetting ColumnKey="MI_ID" ReadOnly="False" />
<ig:EditingColumnSetting ColumnKey="NUM_NOTES" ReadOnly="False" />
<ig:EditingColumnSetting ColumnKey="AL_TIMING" ReadOnly="False" />
</ColumnSettings>
<CellEditingClientEvents ExitedEditMode="dgAllocation_CellEditing_ExitedEditMode" />
<EditModeActions EnableOnKeyPress="True" MouseClick="Single" />
<EditModeActions MouseClick="Single" EnableOnKeyPress="True"></EditModeActions>
</ig:CellEditing>
<ig:RowAdding Alignment="Top" EditModeActions-EnableF2="true" EditModeActions-EnableOnActive="true"
EditModeActions-MouseClick="Single" Enabled="true">
<ColumnSettings>
<ig:RowAddingColumnSetting ColumnKey="Notes" ReadOnly="True" />
<ig:RowAddingColumnSetting ColumnKey="MI_YEAR" ReadOnly="True" />
<ig:RowAddingColumnSetting ColumnKey="CC_ID" ReadOnly="True" />
<ig:RowAddingColumnSetting ColumnKey="CC_NAME" ReadOnly="False" EditorID="FromCCProvider" />
<ig:RowAddingColumnSetting ColumnKey="AL_ACCTTYPE" ReadOnly="False" EditorID="FromTypeProvider" />
<ig:RowAddingColumnSetting ColumnKey="AL_ACCTPATTERN" ReadOnly="False" />
<ig:RowAddingColumnSetting ColumnKey="AL_DESTPATTERN" ReadOnly="False" />
<ig:RowAddingColumnSetting ColumnKey="AL_ALLOCTYPE" ReadOnly="False" />
<ig:RowAddingColumnSetting ColumnKey="ST_NUM" ReadOnly="False" EditorID="AllocationTypeProvider" />
<ig:RowAddingColumnSetting ColumnKey="MI_ID" ReadOnly="False" />
<ig:RowAddingColumnSetting ColumnKey="NUM_NOTES" ReadOnly="False" />
<ig:RowAddingColumnSetting ColumnKey="AL_TIMING" ReadOnly="False" />
</ColumnSettings>
<AddNewRowClientEvents ExitedEditMode="dgAllocation_CellEditing_ExitedEditMode" />
</ig:RowAdding>
<ig:RowDeleting Enabled="true" />
</Behaviors>
</ig:EditingCore>
<ig:Activation>
</ig:Activation>
<ig:Selection CellClickAction="Row" RowSelectType="Single">
</ig:Selection>
<ig:RowSelectors>
</ig:RowSelectors>
</Behaviors>
Function to Update and Insert(allocid is primary key)
—————————————————–
private void updateAllocation()
{
string output = "";
try
{
string rowId = Request.Form["rowId"].ToString();
int year = int.Parse(Request.Form["year"].ToString());
Guid fromCC = new Guid(Request.Form["fromCC"].ToString());
string fromType = Request.Form["fromType"];
string fromAccount = Request.Form["fromAccount"];
string destinationCC = Request.Form["destinationCC"];
string strAllocType = Request.Form["allocType"].ToString();
Guid allocType;
string allocId = Request.Form["allocId"].ToString();
Guid AL_ID;
Guid MI_ID = new Guid();
double al_timing = double.Parse(Request.Form["al_timing"].ToString());
if (strAllocType.Trim() == "FTE" || strAllocType.Trim() == "null")
allocType = new Guid();
else
allocType = new Guid(strAllocType);
foreach (ModelInstance mi in currentMM.ModelInstances)
{
if (mi.modelInstanceYear == year)
{
MI_ID = mi.modelInstanceID;
}
}
AllocationsService svc = new AllocationsService();
if (allocId == "null")
{
AL_ID = svc.insertAllocation(MI_ID, fromCC, fromType, fromAccount, destinationCC, allocType, al_timing, loggedInUserID);
output = rowId + "&&" + AL_ID.ToString();
}
else
{
AL_ID = new Guid(allocId);
svc.updateAllocation(AL_ID, MI_ID, fromCC, fromType, fromAccount, destinationCC, allocType, al_timing, loggedInUserID);
output = "VALID";
}
}
catch
{
output = "INVALID";
}
finally
{
Response.Clear();
Response.Write(output);
Response.End();
}
}
lB_2_9
-
0
Hi,
You cannot get correct value of a cell only in case when you have set the value of cell which does not exist in the drop down items. In that case when you call get_value() the text will be returned.
Can you send a small sample project of your own if you have one, to can investigate this?
-
0
Hello,
I looked at you sample, but I do not see something wrong. As I do not have your db I cannot really reproduce the issue.
I made a sample project similar to you scenario and I still cannot reproduce it. In my project it is reproducible only when the cell value does not exist in the drop down data source.
Please test this project on your side; whether or not it works correctly may help indicate the nature of this issue.
If this sample project is not an accurate demonstration of what you're trying to do, please feel free to modify it and send it back.
Please let me know if I can provide any further assistance.
-
-
- You must be logged in to reply to this topic.
Suggested Discussions
Get cell value of selected row in IgGRID and how to iterate to selected row parents and also get their cell value.
Code: car rows = $(“#grid1”).igGridSelection(“selectedRows”); $.each(rows, …Webdatagrid – How to get value of TemplateDataField – Itemtemplate column value in Javascript client side
Hi, I need to get the cell text value of the Itemtemplate column in javascript. I tried this –…Getting variable value which is set in JSF using javascript in igf_grid.js
Hi, i have hidden variable which is update when the row is selected in GridView, and i need this va…Row.Selected and Selected.Rows.Add behavior in Ultragrid
If I select a row programmatically by setting the row's Selected property to true or by adding …Tags
Created by
Created on
Jun 8, 2015 3:35 PM
Last activity on
Jun 8, 2015 3:35 PM