Telerik RadGrid: Show column only in edit mode? - asp.net

I'd like to "hide" one column in my RadGrid and only have it show when I'm in edit mode. I tried just moving it into the edit item template, but that didn't work at all.
Any suggestions would be deeply appreciated!
Thank you!

Oy...
"Paul's Third Law of Asking For Help
You will discover the obscure answer 5 minutes after giving up and asking for advice."
Turns out you set the column to "Display=False" but only if you are in popup or edit form mode, not inline.
Hope it helps someone else.

Even though you did answer this yourself I thought I'd write an answer to clarify some things.
You can set the default value of the EditColumn to be false, even in InPlace edit. However it makes it a lot more difficult to save edited data as the InPlace edit (for simplicity) requires the EditColumn to display the save or cancel items.
That being said, you can do it - however you need to use explicit CommandNames on the items:
Say you want to Update a row with the new values you have inserted in the InPlace edit. Then the confirm button's CommandName would HAVE to be "Update" to be picked up correctly.
All of this being said, it would be a lot simpler for you to keep the EditColumn intact even when in InPlace (editmode).
Or you could specify the EditTemplate for one column to widen the column, add the two buttons necessary to perform Update and Cancel as well as hiding the EditColumn so that multiple InPlaceEdits can't be performed at the same time. :)
I hope this helps someone, as I was stuck in a similar situation myself when I had to incorporate both InPlace and EditForms EditModes on a single RadGrid and knowing the above information made a WORLD of difference.

You can try this:
var agtype = $telerik.$(atCell).text().trim();
if(agtype == ""Guaranty""){{
var masterTableView = sender.get_masterTableView();
var columnIndex = masterTableView.getColumnByUniqueName(""Amount"").get_element().cellIndex;
masterTableView.showColumn(columnIndex);
}}

Related

add some custom information to node drupal 8

I need to update my referential entity with new values ​​that are inserted every time a user visits the page. I tried to use this code but unfortunately, the latter does not add a value but replaces all of them. I am attaching the code that I used in the hope that someone can help me with this problem. thank you
nodeObj = Node::load(implode($nids));
$nodeObj->set('my_field', $current_user_id);
$nodeObj->save();
If I understand your issue correctly, your code is overwriting the entire value of my_field rather than appending a new value. Also, the implode() and the $nids variable suggest to me that you may be trying to perform this function on multiple nodes at once, which your current code will not do.
Make sure my_field is an ItemList field of some kind.
Try this code:
$nodeObjs = Node::loadMultiple($nids);
foreach ($nodeObjs as $nodeObj) {
$nodeObj->my_field->appendItem($current_user_id);
$nodeObj->save();
}

check box in asp.net webform

I need help in check box my problem that when i select any one it gave me message
about my selection but when choose two of check box gave me the last choose of them why and what is the fix please
What is happening is that your Append status is wrong. Instead of appending, you are overwriting the current value. Hence when you choose say two answers, the first is overwritten by the second.
I think the problem is with the syntax of your Append status. Instead of:
Append(Label5.Text =("New Text"));
It should be something like:
Append(Label5.Text).Append("Your new text");
See:
https://msdn.microsoft.com/en-us/library/b4sc8ca8(v=vs.110).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1

How to detect if an ASP ComboBox is blank.empty

I have an ASP ComboBox that is populated on page load with a list of information and a selected index is set. I want the user to be able to type a new value into the box and run a routine that saves that value.
So far, I've managed to set it so when you run the save routine it can detect the text of the box using;
cboFreeBody.SelectedItem.Text
If the box loads with 'arm' and I change it to 'leg', when I run my routine it grabs the new value and processes it, however if I delete 'arm' and leave it blank when I run the routine the above code returns 'arm', where I'd expect it to return ''.
I'm sorry if I haven't explained myself fully here, I'm rather new to ASP and VB.NET so I'm probably just splurting useless information here, but any help would be greatly appreciated.
I ma not sure but thats might help you..
If com_box.SelectedItem = vbEmpty Then
MsgBox("its empty")
End If
I use the isnullorwhitespace function usually.
if string.isnullorwhitespace(cboFreeBody.SelectedItem.Text) then
else
end if

Checboxes input helper PodsCms

i created a multiple checkboxes input helper adapting the code from this http://podscms.org/packages/checkboxradiobutton-yourvalues/
I modified it so that people don't have to hardcode values into the helper; instead values are taken from the column comment field (having a data field for columns would be appreciated in pods 2.0!)
Here is the helper: http://pastebin.com/w0UxDmnG
I encountered two problems, the first of which i already solved:
At thw beginning i enclosed the whole code in a function, to keep clean the namespace (isn'i it the right thing to do?). but i noticed that i do this, when i have two columns with this helper many strange things happen: the second column is blank, doesn't show checkboxes. After the second column with this helper no more columns are shown.Rich editor commands on all textareas don't appear and textareas themselves are non editable.
I suppose is an effect wrapping the code in a function. Unwrapped the code, problems are gone! (i wrote this because it can be helpful to developers out there.
I wanted to add a "Other" text field for comments outside the choices displayed with checboxes (like in google forms, for example). To trigger this "other" ("Altro" in the package i shared), pod creators have to write [] in the comments (eg: foo, bar, cat, []).
I was able to make the input, but, once data is filled in and the pods is saved, the data in the text field get lost. I really have no idea on how to fix this!
I hope my experience, and this helper could help someone, and i hope some could help me to improve it!
(and please someone create a podscms tag!!)
Pods 2.0 solves this kind of issue, it's now built into core as a field type option. Enjoy!

2 Mutually exclusive RadioButton "Lists"

I think this has to be THE most frustrating thing I've ever done in web forms. Yet one would think it would be the easiest of all things in the world to do. That is this:
I need 2 separate lists of radiobuttons on my .aspx page. One set allows a customer to select an option. The other set does also but for a different purpose. But only one set can have a selected radiobutton.
Ok I've tried this using 2 asp.net Radiobuttonlists controls on the same page. Got around the nasty bug with GroupName (asp.net assigns the control's uniqueID which prevents the groupname from ever working because now, 2 radiobuttonlists can't have the same groupname for all their radiobuttons because each radiobuttonlist has a different uniqueID thus the bug assigns the unique ID as the name attribute when the buttons are rendered. since the name sets are different, they are not mutually exclusive). Anyway, so I created that custom RadioButtonListcontrol and fixed that groupname problem.
But when ended up happening is when I went to put 2 instances of my new custom radiobuttonlist control on my .aspx page, all was swell until I noticed that every time I checked for radiobuttonlist1.SelectedValue or radiobuttonlist2.SelectedValue (did not matter which I was checking) the value always spit back string.empty and i was not able to figure out why (see http://forums.asp.net/t/1401117.aspx).
Ok onto the third try tonight and into the break of dawn (no sleep). I tried to instead just scrap trying to use 2 custom radiobuttonlists altogether because of that string.empty issue and try to spit out 2 sets of radiobuttonlists via using 2 asp.net repeaters and a standard input HTML tag inside. Got that working. Ok but the 2 lists still are not mutually exclusive. I can select a value in the first set of radiobuttons from repeater1 and same goes for repeater2. I cannot for the life of me get the "sets" to be mutually exclusive sets of radiobuttons.
As you have two groups of radio buttons that you want to function as one group of radio buttons, the solution is simple: Make it one group of radio buttons.
The only problem you have then is that the value that you get has the same name from both lists, but that can be solved by adding a prefix to the values so that you easily identify from which list the option comes.
Update: based on the new info posted as an answer. The option I proposed on my original answer corresponds to the 3. You really must consider the following:
Html radio buttons have only 1
built-in mechanism to handle the
exclusivity, which is the name.
You are explicitly requesting a no js solution, so given the above you must manipulate the Ids to achieve it. If you weren't blocking this option I am sure someone would come up with some nice jquery or js library that already supports it.
The option 3 is clearly the less invasive, as you are not forced to affect the actual data, and are not affected by future updates to it.
It's not that much code, just something extra on the List indexes, and some simple thing as:
int? list1Value = null;
int? list2Value = null;
var value = Request.Form["somegroup"];
if (value.StartsWith("List1"))
list1Value = int.Parse(value.Substring(5));
else
list2Value = int.Parse(value.Substring(5));//Assuming List2 as prefix
Original:
I saw your other question, and you just need to use the same group name. Make sure you have different values for all items regardless of the list they come from. A way to achieve this is adding something to the values, like: <%# "List1-" + Eval("ID") %> and modifying the code that reads your Request.Form["yourgroupname"].
I think you should just use RadioButtons instead of RadioButtonLists.
Here's an article that presents a solution to resolve the radiobutton naming bug.
Though this post is dated 1 year ago already, I just read it because I face the same problem.
Currently I have 1 solution using jQuery:
Client side script (you must also include jQuery)
function SetRadio(rb) {
$('input:checked').attr('checked', false);
rb.checked = true;
}
For every radiobutton (which is a listitem in a radiobuttonlist) I add the following on the serverside:
li.Attributes.Add("onclick", "javascript:SetRadio(this)");
For me this works in both IE and Firefox, with 3 radiobuttonlists, without using groupnames.
You can check each radiobuttonlist for a selecteditem/value, or you can extend the SetRadio function so it stores the selected value in a hidden field.
Regards,
M

Resources