How to get ID for onRowSelected event for asp.net webforms jqGrid? - jqgrid

I have implemented server side jqgrid with the following code
<trirand:JQGrid ID="jQGrid1" runat="server" OnDataRequesting="jQGrid1_DataRequesting" Height="220" LoadOnce="false" OnRowSelecting="jQGrid1_RowSelecting">
<AppearanceSettings ShowRowNumbers="true" />
<Columns>
<trirand:JQGridColumn DataField="AppId" HeaderText="Application ID" PrimaryKey="True" Width="100" />
<trirand:JQGridColumn DataField="Name" HeaderText="Application Name" Width="200"/>
<trirand:JQGridColumn DataField="Link" Width="280" />
</Columns>
<PagerSettings ScrollBarPaging="true" PageSize="20" NoRowsMessage="scroll down to fetch records" CurrentPage="1"/>
</trirand:JQGrid>
But for the onRowSelected Event when i check in my c# code i was getting selected index as some random values like jqg11,jqg25,....
why is it happening .What should i do to make one of my column to set as key when selected
I have checked below options
jQGrid1.SelectedRow
e.RowKey

I don't use commercial version of jqGrid, thus the code which you posted say me almost nothing. Nevertheless the reason of ids like jqg11 and jqg25 are typically errors in filling of the grid. jqGrid requires to assign id attribute to every row. So the server response should contains the id values. The exact information depends on the format of input data which you chosen, from the version of jqGrid which you use and from other options like id property of jsonReader or the existence of key: true property in one column of colModel. I recommend you to verify the JSON/XML data which you use to fill the grid. Probably you ddidn't specified correctly the id values.

Related

Can't display my own id in apex:inputField in browser

I am very new to apex and just start to study how to add validation on the field. I am not able to do this from set up. In more detail I want to assign an id to apex:inputfield. I read a lot of information in the internet such as using partial id like http://www.kineticgrowth.com/javascript-visualforce-jquery-partial-id-selectors/
However know matter what I add in apex page, it doesn't show up inside the string. Here is my code:
<apex:pageBlock id="pageBlock" ...>
...
<apex:dataTable ... id="transTableBrandPurchase" ">
...
<apex:inputField id="eric_test" value="{!varBla}" required="true" />
when I check the browser in html it gets
<input id="j_id0:j_id6:pageBlock:transTableManufacturerPurchase:0:j_id273" maxlength="255" name="j_id0:j_id6:pageBlock:transTableManufacturerPurchase:0:j_id273" size="20" type="text">
Based on Salesforce reference I should get id="j_xxx:j_yyy ...:pageBlock:transTableManufacturerPurchase:eric_test"
People may say that I can just use "pageBlock:transTableManufacturerPurchase", I cann't because in this page we display then rows and the other rows look like similar:
<input id="j_id0:j_id6:pageBlock:transTableManufacturerPurchase:0:j_id275" name="j_id0:j_id6:pageBlock:transTableManufacturerPurchase:0:j_id275" >
Right now I am working on validation in visualforce page with Jquery.
My approach to assigning ID to elements in VF page is, give ID to all apex elements. Then use chrome inspect element option to find exact ID.
If you are using salesforce any repeat tags , , etc, salesforce will add additional numbering on your ID, to make sure that all elements have unique ID.

How to reRender an inputText generated dynamically by a dataTable using Ajax

I'm using here in my project JSF 1.2 and the Tag <a4j:support> .
Well, i'm using here a <h:dataTable /> to print on the screen a list of financial expenses, where it's possible for the user to insert new expenses or edit the existed expenses at anytime, the value of these expenses fields (amount, balance, value) are being shown in inputTexts components.
As i'm using a <h:dataTable /> the inputTexts of it are generated automatically, so it creates dynamical inputTexts with dynamical ids. I took a look at the html source code of the page and the pattern JSF uses to generate the ids in a dynamically way is this:
id="formTemplate:tableForm:0:inputTextValue" ;
id="formTemplate:tableForm:1:inputTextValue" ;
id="formTemplate:tableForm:2:inputTextValue"
And in the xhtml page the code i used with the dataTable is this:
<h:inputText id="inputTextValue" value="#{item.value}" label="Value" styleClass="field" size="9" readonly="true" dir="RTL" style="font-size:12px;width:170px">
My business rule works like that: When the user types something in the inputTextBalance it calls the event onBlur where it automatically inserts an other value in the field "value", but to update this inputTextValue i need to do a reRender in my panel (panelDataTable), so it reRender the whole dataTable (dataTable is inside the Panel).
<h:inputText id="inputTextBalance" value="#{item.balance}" dir="RTL">
<f:convertNumber currencyCode="BRL" type="currency" />
<a4j:support event="onblur" reRender="panelDataTable" ajaxSingle="true" action="#{expenses.update}"/>
</h:inputText>
Now comes the trouble, what i need to do is to reRender only the inputTextValue instead of the panel, but these fields are generated dynamically and i can't get there ids. Like i said before, this is the pattern that JSF uses to generate the id of the fields
id="formTemplate:tableForm:0:inputTextValue" ;
id="formTemplate:tableForm:1:inputTextValue" ;
id="formTemplate:tableForm:2:inputTextValue"
But when i use any of these ids in reRender attribute, the Ajax's log returns me this message:
18:23:57,208 WARN [AjaxContext] Target component for id formTemplate:tableForm:0:inputTextValue not found
I tried this but i got the same error message: reRender="#{rich:clientId('inputTextValue')}"
The weirdest thing here is that it shows me this message of the input not found, but in the html source code the id of he inputText is the same that i've puted to reRender.
Does anybody here have already delt with this problem? Any suggestions to me?
Thank you!
you should bind the h:dataTable to a variable in your bean, in order to reach the current row index.
<h:dataTable binding="#{myManagedBean.dataTable}" ...>
then you can change a4j:support like this:
<a4j:support reRender="formTemplate:tableForm:#{myManagedBean.dataTable.rowIndex}:inputTextValue" ... />

Using of a4j:commandLink; how it works?

In my project I have the facelet, which contains the following chunk of markup:
<rich:column sortable="true" sortBy="#{item.date}">
<a4j:commandLink value="#{item.dateView}"
reRender="reportTable">
<a4j:actionparam name="shown" value="#{not item.showDetails}"
assignTo="#{item.showDetails}" />
</a4j:commandLink>
</rich:column>
After I've clicked to the commandLink I have that my table is reRendered with an additional data. But I completely don't undertand how it works. I've read a corresponding manual page about one, but it is still not clear. In the manual's example we use the following tag:
<a4j:commandLink value="Get greeting" reRender="greeting" />
And after we've clicked to it we get a message "Hello %name%". Where is the String template for the "Hello %name%" message is located. In the other word, I would like to enquire where the data that I reRendered is located?
a4j:commandLink assigns (boolean) value of !item.showDetails into item.showDetails and re-render reportTable. Your additional data (which you see after click to command link) is displayed after re-rendering of table, because there is (probably rendering) condition similar to "#{item.showDetails}".

Joomla 2.5 registration custom field as dropdown?

I added some extra field to Joomla 2.5. Everything working great. For example, I added "country" to registration.xml (components/com_users/models/forms):
<field name="country" type="text"
description="COM_USERS_REGISTER_COUNTRY_DESC"
filter="string"
label="COM_USERS_REGISTRATION_COUNTRY"
required="true"
size="40"
/>
But how to add a dropdown list? I want to give my users ability to select country from the list.
And similar question: I also added birthday field. How to add jQuery datepicker here?
In my opinion you should not edit Joomla core files. This could break your installation in future updates.
Although I don't recommend it, take a look at Standard form field and parameter types # Joomla Docs. At that page, see list for your dropdown list and calendar for your date.
Another way of adding extra fields would be with a extension. Check out:
ExtendedReg (commercial)
Community Builder
Joomla 2.5 has a 'profile' plugin to handle extra registration fields. You can edit that or write your own plugin. This avoids editing core files. Example of a country list using a database call (your database must have the table of counties). My table has country codes in two and three letters and I want to save the 3 letter code (example CAD).
<field
name="country"
type="sql"
id="country"
description="PLG_USER_PROFILE_FIELD_COUNTRY_DESC"
filter="string"
label="PLG_USER_PROFILE_FIELD_COUNTRY_LABEL"
message="PLG_USER_PROFILE_FIELD_COUNTRY_MESSAGE"
query="SELECT country_3_code as value, country_name as country FROM #__mycomponent_country
ORDER by country"
/>
For birthday use:
<field
name="birthday"
type="calendar"
label="Birth Day"
description="My Desc."
/>
And for country use the SQL as mentioned by #Gord Fisch

Telerik RadGrid - How to disable sorting for a Column?

In their documentation Telerik says that there is a way to disable sorting for specific column by using AllowSorting property. I'm looking at Telerik.Web.UI.GridColumn members and there is no AllowSorting property. There is a Sortable property but its protected and has to be overriden. So what do I use to turn off sorting for specific column?
There is a AllowSorting property on GridBoundColumn but in this case I'm using GridTemplateColumn. Is there a way to turn off sorting on GridTemplateColumn?
The AllowSorting attribute is available from the source/markup view in Visual Studio. For example (simplified):
<tr:RadGrid>
<MasterTableView>
<Columns>
<tr:GridBoundColumn DataField="field" HeaderText="Description"
AllowSorting="false" />
</Columns>
</MasterTableView>
</tr:RadGrid>
I don't know if this works for you? I haven't instantiated my grids from the code-behind files yet, so if that's what you are doing, I can't easily help you. But the above works for me.
EDIT:
Ah it was not clear from the original question, that you were using the GridTemplate column. As you are now using the SortExpression-property, doesn't using the same attribute in the markup work for you? So:
<tr:RadGrid>
<MasterTableView>
<Columns>
<tr:GridTemplateColumn HeaderText="Description" DataField="field"
SortExpression="">
<!-- template here etc. -->
</tr:GridTemplateColumn>
</Columns>
</MasterTableView>
</tr:RadGrid>
Okay, I got the desired effect, I turned off sorting by setting GridTemplateColumn's SortingExpression property to blank.
Grid.Columns.FindByUniqueName("Type").SortExpression = string.Empty;
This looks like a hack. Why isn't there an explicit property to turn off sorting? Oh well. This works.
If you know a better way, let me know.
Thanks.
Telerik now has a new property called HeaderButtonType (exists on a template column too!) which can be set to "None" to render a label instead of a linkbutton for the column header text.
As stated in the Telerik Docs:
In case you want to disable sorting for a particular column only, you can configure column's IsSortable property to False:
<telerik:GridViewColumn IsSortable="False" />
Here's an example showing how to disable sorting for a specific column.
Note the AllowSorting property at the Grid level (for all columns).
Then, in the Columns collection, note how it is turned off for that specific column.
<telerik:RadGrid ID="RadGrid1" runat="server" AllowSorting="True">
<HeaderContextMenu>
<CollapseAnimation Duration="200" Type="OutQuint" />
</HeaderContextMenu>
<MasterTableView>
<RowIndicatorColumn>
<HeaderStyle Width="20px" />
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px" />
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn AllowSorting="False" UniqueName="column">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<FilterMenu>
<CollapseAnimation Duration="200" Type="OutQuint" />
</FilterMenu>
</telerik:RadGrid>
For TemplateColumns, I would try turning off Sorting at the grid level and simply enable it on the columns needed. That way, you won't have to do anything for the TemplateColumn since it will be disabled by default.
You could always supply your own headertemplate with a label as the header instead of a link button if you are using a GridTemplateColumn. A we bit extra work but this works fine. If you are going to disable sorting for all your GridTemplateColumns then your "hack" would be best.

Resources