make a cell as template field in GridView - asp.net

I have a grid view which is dynamically populated with data. and the no.of columns may be changed each time according to the query.. i want to make the first field to select the row of data(by making it template field). I cannot declare statically the columns as template fields because the column numbers are dynamic.
can any one help how to proceed.

You need to create your own template builder - a class implementing ITemplate interface - use InstantiateIn to build your template by adding needed controls to the given template container. Add TemplateField column to the grid-view and use your class as ItemTemplate.
See this article where this is illustrated: http://www.mindfiresolutions.com/How-to-add-a-TemplateField-to-a-GridView-dynamically-841.php
Further, what you want to achieve might be possible by creating your custom DataControlField - for example, for selection column, I may use a class inherited from CheckBoxField (something like http://www.asp.net/data-access/tutorials/adding-a-gridview-column-of-checkboxes-cs)

It's a bit of work but the following article walks through all of the steps: How to create template columns dynamically in a grid view
There is no easy answer for what you're trying to do but the above link will help you if you are willing to put in the time and effort to get it done.

Related

Datasource in create and "normal mode for the same form

I would like to create a single form that I can bind to a datasource in create mode and in "normal mode". The use case is that I can have an existing item in the datasource that I would like to edit, or I would like to create a new one.
I can't find a way to dynamically switch the datasource mode before opening the form. It seems that 2 forms are required to accomplish this.
Any suggestions on how to accomplish this?
It is possible to reuse form fields, but you'll still need at least two forms (containers). The idea is to create a page fragment with datasource derived from some model:
then you can add this page fragment to form (container) and override datasource.
Normally you would choose between normal mode:
#datasource.item
...and create mode:
#datasource.modes.create.item
You can find complete code sample in Project Tracker template and learn more about create mode in docs:
https://developers.google.com/appmaker/models/datasources#create_mode_datasource

Kendo UI grid subrow

I need to develop a Kendo grid as the one in the mockup that follow:
This is simple, but when a special value is selected in one of the select fields, a sort of sub-row must be displayed:
So, this set of 3 (or 6) fields is what I need to have on every grid row. That means I need to add other rows like this, being able to liveedit them or delete.
I'm wondering what is the best way to reach this (if possibile).
Can I simply define the whole set of fields (with sub-row) as a single grid row then split someway it using CSS or Kendo grid already support this kind of layout?
The Kendo UI grid is a widget which allows you to visualize and edit data via its table representation, KendoGrid is not best approach in my opinion.
You just need to create on kendo template, with you 3 static dropsdown's and when you click on your "special" value you will have to append your template again with other data if is needed.
Check on KendoTemplate docs.
EDIT: So you will have to use kendogrid detail (hardcoded), and use tempate to show you 3 fields I think.
Hope this help

Is there a way to arrange the columns in the grid when the Sales order list page is loaded?

I'm stuck with an issue in the sales order Grid in Dynamics AX 2012 R2. Somehow after adding new columns to the grid via personalization, the newly added columns always shifts to the left side after closing/opening the sales order list page.
Is there any Grid property that handles the arrangement of the columns?
how can we modify the grid columns?
Thanks!
Well, it sounds like an error, this is not how it works for me.
Consider adding the fields to the SalesTableListPage form. The fields are initially (or after reset of user settings) listed in the order in the form grid.
Might look into the list page interaction classes which is responsible for form behavior instead of the AOT on listpages.
more information on the available methods can be found on msdn
https://msdn.microsoft.com/en-us/library/listpageinteraction.aspx
but it is possible for example that a var/isv customization modifies the form after it is loaded

How to dynamically bind a Query to a grid?

I have a Query that the datasources it is set to can change dynamically. I want to take the results of this Query and bind that to a Grid, so each time it may have new fields, and data.
I already added a Grid to my form, and added the Common table as a datasource. I tried to set the dataSource of the grid, and iterate through the fields and dynamically add them, but no data is showing up.
Have a look on the form SysTableBrowser.
It builds the grid based on a tableId.
Maybe you can change SysTableBrowser to accept a query.
Good luck!

Grid View Generic Functions

currently I am using few generic functions/methods in gridview for Sorting Images and Getting Header Row in TH and merge Header Row.
Link
http://marss.co.ua/MergingGridViewHeaderColumns.aspx
problem is i have to write these function for every Grid. I looking for solution, Where I can define these behaviors only at one place.
Create an object that inherits from the GridView. Add your properties and functionality to that new object. On your page add that new object instead of the GridView. And if you go totally nuts like I did, you can end up creating a totally different control. See the
GridViewTree.

Resources