Jump to content
Software FX Community

Selecting first record on Grid


KodgireVijay

Recommended Posts

Hi,

We are using the GridFX component from long time. We are facing with some tricky situation. Currently, as per the GridFX recommandations, we are binding the datasource using the OnDataSourceSelecting event.

We are setting the first record as selected through the OnRendering event. For the Selection, we are using the ClientOnly as ChangeAction. Also we have enabled the Sorting/ Paging feature for the Grid.

When user clicks on any record (before sorting/ paging), grid shows only that record as highlighted.

When user Sorts the data on any column, first record is shown as highlighted, through the Rendering event. However the problem is if user clicks on any other row in the gird, Grid displays two record as highlighted.

Earlier we were not facing this issue when we were using the other binding method/ Selection (through the Postback ChangeAction).

Is there any issue with these events?

If not kindly suggest the way to fix this behaviour.

Thanks for the response.

Link to comment
Share on other sites

Thanks for the quick response. Here is the GridFX markup. 

<

GridFX:grid id="PhysCovGrid" runat="server" CssClass="gridFx-non-modal" height="220px" width="550px" DataSourceInCode="true" OnDataSourceSelecting="PhysCovGrid_DataSourceSelecting" Motif="Elegant" Palette="Default" OnRendering="EnableDisableSelect">

<

Selection ChangeAction="ClientOnly" Style-CssClass="gridFx-selection"/>

The EnableDisableSelect method code.

protected void EnableDisableSelect(object sender, EventArgs e){int countItem = PhysCovGrid.Items.Count;

if (countItem > 0) {PhysCovGrid.Items[0].Selected = true;}

}

}

 

Link to comment
Share on other sites

<Columns>

<GridFX:FieldColumn Title="Cov ID" Field="phys_cov_id" Visible="False"></GridFX:FieldColumn>

<GridFX:FieldColumn Title="Start Date" Field="cov_start_date" Width="70px" Style-CssClass="gridFx-cell" Style-Header-CssClass="gridFx-header" Style-Wrap="False" />

<GridFX:FieldColumn Title="End Date" Field="cov_end_date" Width="70px" Style-CssClass="gridFx-cell" Style-Header-CssClass="gridFx-header" Style-Wrap="False" />

<GridFX:FieldColumn Title="Physician Status" Field="phys_status_desc" Width="70px" Style-CssClass="gridFx-cell" Style-Header-CssClass="gridFx-header" Style-Wrap="False" />

<GridFX:FieldColumn Title="Specialty" Field="primary_splty_desc" Width="100px" Style-CssClass="gridFx-cell" Style-Header-CssClass="gridFx-header" Style-Wrap="False" />

<GridFX:FieldColumn Title="Sponsor" Field="short_name" Width="200px" Style-CssClass="gridFx-cell" Style-Header-CssClass="gridFx-header" Style-Wrap="False" />

<GridFX:FieldColumn Title="Employer" Field="employer_short_name" Width="100px" Style-CssClass="gridFx-cell" Style-Header-CssClass="gridFx-header" Style-Wrap="False" />

</Columns>

<DataFields><GridFX:NumberField DataPath="phys_cov_id"></GridFX:NumberField>

<GridFX:DateTimeField DataPath="cov_start_date">

<Sorting Direction="Descending" />

</GridFX:DateTimeField>

<GridFX:DateTimeField DataPath="cov_end_date"></GridFX:DateTimeField>

<GridFX:TextField DataPath="phys_status_desc"></GridFX:TextField>

<GridFX:TextField DataPath="primary_splty_desc"></GridFX:TextField>

<GridFX:TextField DataPath="short_name"></GridFX:TextField>

<GridFX:TextField DataPath="employer_short_name"></GridFX:TextField>

</DataFields>
Link to comment
Share on other sites

This is mainly a timing issue.  During the Rendering, the grid's client-side initialization script has already been committed to the page.  If you select an item after that, the client-side control will not know the first item is selected (the item is selected because the css classes are applied).  So when you click on another item the client-side control doesn't unselect the first because it has no idea the first one was selected.

The easiest fix is to most your code to the Page's OnPreRenderComplete, such as:

public partial class WebForm12 : System.Web.UI.Page

{

protected override void OnPreRenderComplete(EventArgs e)

{

Grid1.Items[0].Selected = true;base.OnPreRenderComplete(e);

}

Let me know if this helps.  Thanks again!

Link to comment
Share on other sites

Thanks for the response. We implemented the OnPreRenderComplete event. With this event, on page load the grid was showing the first record as selected. But now if user sorts the data in grid or moves to next page, first record is not shown as highlighted.

To show the first record as highlighted after sorting/ paging, we need to implement the OnRendering event for the Grid. If we implement the OnRendering event, first record is shown as highlighted, even after sorting/ Paging. However we face issue in this case too. If user selects any other record than the first one, grid shows two records as highlighted (the first record highlighted through the OnRendering event, second record selected by user).

We are still having the issue. Please let us know if there is any way to fix this problem.

Thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...