0

I am using jqGrid to display the database table and loading the JQGrid using DataSet from ASP.NET code behind file. Columns are also generated from code behind file at the runtime. I have two columns (PrimaryKey column[which is not auto-increment field], Text Field column) and I want to provide add functionality to both the columns using add-form but edit functionality to only one column i.e Text field column using inline editing.

This is similar to the question reported here and the answer is pretty close to what I want. I found other solutions as well but most of the solutions use data in JSON format and are loaded from Javascript.

I am having a hard time figuring out the above functionality because the data is already loaded from the database and I just wish to modify the editable property. By default I have Primary field not-editable and Text field - editable.

I would really appreciate any help.

Community
  • 1
  • 1
Ann
  • 18
  • 6

1 Answers1

1

The answer which you reference is oriented on the inline editing mode. In case of usage of form editing I can recommend you to follow this. You can combine both to force inside of beforeShowForm both columns be editable in the Add form and making only one column editable in case of Edit form or inline editing.

UPDATED: From the email which you send me I could first of all find out that you used wrong tag jqgrid for your question instead of jqgrid-asp.net. So you used commercial jqSuite product instead of free open source JavaScript jQuery plugin jqGrid. I answered you how you can solve the problem in jqGrid, but your problem was how to use the same in the .NET classes which provide jqSuite.

In the case you can find the solution in the answer. You should just fix the typing error in the code and use different properties JQGrid1.ClientSideEvents.AfterAddDialogShown and JQGrid1.ClientSideEvents.AfterEditDialogShown.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Thank you for replying but the problem which I am facing is that I do not have this section
    `jQuery("#list").jqGrid({ data: mydata, colModel: [ ]//... })`
    as the data is populated in the jqgrid from the code behind file & when I try to write only the last part with beforeShowForm as in your example, grid doesn't display anything.
    I am using jqgrid for the first time and don't know right way to do this functionality. I have seen couple of your answers and they are really to the point but I have failed to apply those answers here. Could you please suggest some code to solve this?
    – Ann Jun 04 '12 at 21:16
  • @user967539: I am not sure that I understand you correct. If you set `editable: true` initially in all columns or if you just use `cmTemplate: {editable: true}` (see [here](http://stackoverflow.com/a/6047856/315935)) then you should have no problems. You will need to *hide* some editable columns inside of `beforeShowForm` to make there non-editable in the way. – Oleg Jun 04 '12 at 21:26
  • Thank you so much for your help. It worked! and I am sorry for my mistake – Ann Jun 06 '12 at 15:13