We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Grid Binding Problem

HI

Your provided all samples are very useful to us, and our client is also going to buy your product, as per our client requirements we are using your "Grid Control" and we are customizing as per requirements , let me first clear our requirements :

1. There will be some binding customization options as below :  
   
   A. Dropdown 1 for selecting the table from which Grid will bind.
   B. As we select any table from First Dropdown then the perticualar table's columns will be shown in DropDown 2
   C. Then user can select multiple columns from the Dropdown 2 
   D. So as per selected data from Dropdown 1 and Dropdown 2 Grid will be binded.

So we are working on this but facing some binding problems, can you please help us to overcome from this problem and provide a sample as per requirements, it will save our time and we can move forward to other important things.

Thanks
Neeraj Purohit


11 Replies

NE Neeraj November 10, 2014 05:44 AM UTC

Hi

We are very close to implement your tools in our project and also trying to figure out the problem which I have already mentioned above.

Please look into matter and provide us a sample as per our requirements ASAP. Your quick response will be appreciated.

Thanks
Neeraj Purohit


SA Saravanan Arunachalam Syncfusion Team November 11, 2014 03:19 PM UTC

Hi  Neeraj,

 

Sorry for the delay to get back you.

 

We are glad to let you know that we have created sample for your requirement and the same can be downloaded from the following location.

 

Sample Location: http://www.syncfusion.com/downloads/support/directtrac/general/Samplec1-908437433.zip

 

In the above sample, We have created two dropdown list and one button. On the first dropdown  “change” event, we have retrieved column list using “ajax post”  and then we have updated second dropdown list  in ajax success using “setModel” of Dropdown. Please refer the following code snippets to achieve your requirement

 

 

function change(arg) {

                         . . . . . . . . . .

                         $.ajax({

                url: "ColumnChooser.aspx/GetData",

                . . . . . .

                success: function (data) {

                    var temp = $("#DropDownList2").ejDropDownList("instance");

                    temp.setModel({ dataSource: data.d, showCheckbox: true });

               }

            });

}

 

public static object GetData(string table)

        {

            . . . . . . .  . . .            

            var columnName = GetColumns(table);

            return columnName;

           

        }                  

 

 

 

 We have selected the required columns from the second dropdown. Then on  button  “click” event we have retrieved corresponding data from server-side based on dropdown values using ajax post. On that  ajax success we have updated Grid datasource using “dataSource” method of Grid. Please refer the following code snippets to achieve your requirement.

 

 

 

function onClick(arg) {

      

            . . . . . . . .

 

            $.ajax({

                url: "ColumnChooser.aspx/getRecords",

                . . . . . .

                success: function (data) {

                     

                       . . . . . . . .

                       $("#FlatGrid").ejGrid({dataSource: query });

                  }

            });

        }

 

public static IEnumerable getRecords(string table)

        {

          

            IEnumerable dataSource =null;

 

               if (table == "Employees")

                   dataSource = new NorthwindDataContext().EmployeeViews.ToList();

               if (table == "Orders")

                   dataSource = new NorthwindDataContext().OrdersViews.ToList();

            

            return dataSource;

           

        }

 

 

 

 Please let us know if you have any queries. We are happy to assist you.

 

Regards,

Saravanan.A

 



NE Neeraj November 12, 2014 05:11 AM UTC

Hello Saravanan

Well... I have reviewed your provided sample but as you said above that you have created two 'DropDowns' and 'Button' and from their 'change' and 'Onclick' event Grid will bind, but such functioning is not there in sample.

When I run the application, Grid is binded from some default data. I have attached a screenshot of it, you can see that neither Dropdowns nor Button is there.

So you know its quite frustrating that you provide me a sample after couple of days and then its not working as per our requirements. Please provide us a sample which fulfil our requirements so that we can work in smooth way.

Hoping for a good sample....

Thanks
Neeraj Purohit

Attachment: grid_1cb2eb0c.rar


MS Madhu Sudhanan P Syncfusion Team November 12, 2014 12:41 PM UTC

Hi Neeraj Purohit,

 

We deeply regret for the inconvenience caused and please ignore the previous update.

 

We have created a simple grid sample in which the grid datasource can be rendered based on the dropdown values and the same can be downloaded from the below location.

 

Sample Location:  http://www.syncfusion.com/downloads/support/directtrac/general/DataBinding-Forms741345001.zip

 

In the above sample, the grid is initially loaded with the data from Orders table. And there are two dropdownlist available at the page in which one drop down list contains table names. The second dropdownlist will loaded with the corresponding column names available in the table selected in first dropdownlist. The second dropdownlist will be updated with the column names from server based on the value selected in the first dropdownlist in the change event as follows.

 

 

<div class="col-md-3" style="margin-top: 10px">

            <label>Select Columns</label>

            <ej:DropDownList ID="drop1" runat="server" ClientSideOnChange="getColumns"//Table Dropdownlist

                <Items>

                    <ej:DropDownListItem Text="Orders" Value="Orders" />

                    <ej:DropDownListItem Text="Employees" Value="Employees" />

                </Items>

            </ej:DropDownList>

            <br />

            <label>Select Table</label>

            <ej:DropDownList ID="drop2" runat="server" ShowCheckbox="true"> //Column dropdownlist

            </ej:DropDownList>

            <br />

            <br />

            <ej:Button ID="done" runat="server" Type="Button" Text="Done" Size="Normal" ShowRoundedCorner="true" ClientSideOnClick="bindData">

            </ej:Button>

        </div>

 

<script>

        function getColumns(args) {

            var val = this.getSelectedValue();//get table name

            $.ajax({

                url: "Default.aspx/getColumns",

                type: "POST",

                contentType: "application/json; charset=utf-8",

                dataType: "json",

                data: JSON.stringify({ table: val }),

                success: function (data) {

                    var drop2 = $("#drop2").ejDropDownList("instance");

                    $("#drop2").ejDropDownList({ dataSource: data.d, showCheckbox: true }); //binding the column names from the server

                }

            });

        }

 

        function bindData(args) { //ejButton onclick event

            var cols = $("#drop2").ejDropDownList("model.value"); //get selected column values

            var table = $("#drop1").ejDropDownList("getSelectedValue"); //get table name

            $.ajax({

                url: "Default.aspx/getRecords",

                type: "POST",

                contentType: "application/json; charset=utf-8",

                dataType: "json",

                data: JSON.stringify({ table: table }),

                success: function (data) {

                    $("#OrdersGrid").ejGrid("destroy"); // destroy grid

                    $("#OrdersGrid").ejGrid({ dataSource: data.d, query: ej.Query().select(cols.split(",")), allowPaging: true }); //re-rendering grid with new data from server

                }

            });

        }

    </script>

 

 

We have returned the column names and records from the server using the webmethod and it is as follows.

 

 

[System.Web.Services.WebMethod] // Return  column names based on table

        public static IEnumerable getColumns(string table)

        {

            var model = new AttributeMappingSource().GetModel(typeof(NorthwindDataContext));

            List<string> cols = new List<string>();

            foreach (var mt in model.GetTables())

            {

                if (mt.TableName == "dbo." + table)

                {

                    foreach (var dm in mt.RowType.DataMembers)

                    {

                        cols.Add(dm.MappedName.ToString());

                    }

                }

            }

            return cols;

        }

 

[System.Web.Services.WebMethod] //Return records

public static object getRecords(string table){

            if(table == "Employees")

                return new NorthwindDataContext().EmployeeViews.ToList();

            else if(table == "Orders")

                return new NorthwindDataContext().OrdersViews.Skip(0).Take(100).ToList();

            return "Table not found";

        }

 

 

The output of the above provide sample will look like follows.

 

 

Please let us know if you have any queries.

 

Regards,

Madhu Sudhanan. P



NE Neeraj November 13, 2014 07:29 AM UTC

Hello Madhu Sudhanan P,

Your sample is not working, whenever I run application it shows some error. I am attaching screenshot of the error.

With this I want to share some cases so that you can cover these cases in updated sample : 

 Case 1 : 
 
1.  user can select multiple tables and multiple column to bind the Grid, so for that how we can handle this.

For example :  Grid is containing 5 columns in which 2 columns are bonded from Table1 and next 3 columns are bonded from Table2 then how it is possible to bind the multiple data from multiple tables in one Grid ?

I am attaching screenshot for you ease so that in next sample you handle this case.

Case 2 : 

1. Your sample is based on simple queries like "SELECT * FROM Table 1", but if user want to bind Grid with multiple tables with the use of "JOINS" then your sample will not work, so this also very important case because its up to user that he wants to bind Grid with one table or from multiple tables, please also handle this case in next sample.

I hope I have clarified all the possible cases, so please provide me a sample with out any error ASAP

Thanks
Neeraj Purohit



Attachment: grid_req_c9e3cc6a.rar


MS Madhu Sudhanan P Syncfusion Team November 14, 2014 09:41 AM UTC

Hi Neeraj, 

 

The sample provided in the previous update is created using Essential Studio Volume 3, 2014 (12.3.0.36). From the attached screenshot, we suspect that you are using different version and hence the error occurred. Also we have analyzed your requirement and we need to create custom sample to achieve your requirement and so we suggest you to create incident with details such as Essential Studio version you are using and your requirement details.

 

Please let us know if you have any queries.

 

Regards,

Madhu Sudhanan. P



NE Neeraj November 14, 2014 10:47 AM UTC

Hi Madhu Sudhanan P,

As you are saying I will create a incident for the issue I am facing but as per my understanding there is no need to add my Custom requirements into that incident because I always mention my requirements in Forum so please provide me a sample as per our requirements.

Thanks

Neeraj Purohit



NE Neeraj November 17, 2014 04:23 AM UTC

Hello

We are waiting for your response, as I have mentioned earlier our requirements regarding Grid, please provide us a sample so that we implement and modify it as per our requirements.

Thanks
Neeraj Purohit



MS Madhu Sudhanan P Syncfusion Team November 18, 2014 06:37 AM UTC

Hi Neeraj,

 

Sorry for the inconvenience caused.

 

Normally we will provide immediate solutions alone in forum. But your requirement requires more analysis and work. Hence we suggested you to create incident, so that we can achieve your requirement through custom sample. And also we noticed that you have created incident #132023 which is currently in sales pending, so please provide your requirements in that incident for better follow up.

 

Please let us know if you have any queries.

 

Regards,

Madhu Sudhanan. P



NE Neeraj November 18, 2014 07:20 AM UTC

Hello Madhu Sudhanan P,

As per your suggestion I have posted my requirements in that incident which you have mentioned above.

I will come back to you if any other help will be needed.

Thanks
Neeraj Purohit


AR Ajith R Syncfusion Team November 25, 2014 06:36 AM UTC

Hi Neeraj,

Thanks for your update.

We will wait to hear from you. Please follow-up the incident #132023 for further details about your query.

Please let us know if you have any concerns.

Regards,

Ajith R


Loader.
Live Chat Icon For mobile
Up arrow icon